Macro const_base::encode_as_str [−][src]
macro_rules! encode_as_str { ($slice : expr, $config : expr $(,) *) => { ... }; }
Expand description
Encodes the $slice constant into a &str with the encoding determined by $config.
$slice can be a &'static str, &'static [u8; N], or &'static [u8].
Examples
Base 64
use const_base::{encode_as_str, Config}; { const OUT: &str = encode_as_str!("qux", Config::B64); assert_eq!(OUT, "cXV4"); } { const BYTES: &[u8] = b"goodbye"; // this macro can encode non-literal constants const OUT: &str = encode_as_str!(BYTES, Config::B64_URL_SAFE); assert_eq!(OUT, "Z29vZGJ5ZQ=="); }