Skip to main content

as_str

Function as_str 

Source
pub const fn as_str(bytes: &[u8]) -> &str
Expand description

The key macros’ const from_utf8, which is how a computed key reaches the &'static str the rest of the crate wants without an unsafe block.

§Panics

At compile time, if the bytes are not UTF-8. Neither caller can produce that: cased changes the case of ASCII bytes and copies every other byte through, and quoted_key wraps a key in ASCII punctuation. Both operations preserve UTF-8, and this is what says so without an unsafe block.