surrealpatch/lib/src/key/debug.rs
Przemyslaw Hugh Kaznowski 769ed5ab85
Sur 253 Change Cl->Nd, rework key/mod (#2257)
Co-authored-by: Tobie Morgan Hitchcock <tobie@surrealdb.com>
2023-07-18 18:32:38 +00:00

14 lines
467 B
Rust

/// Debug purposes only. It may be used in logs. Not for key handling in implementation code.
use crate::kvs::Key;
/// Helpers for debugging keys
/// sprint_key converts a key to an escaped string.
/// This is used for logging and debugging tests and should not be used in implementation code.
pub fn sprint_key(key: &Key) -> String {
key.clone()
.iter()
.flat_map(|&byte| std::ascii::escape_default(byte))
.map(|byte| byte as char)
.collect::<String>()
}