Macro const_format::unwrap
source · macro_rules! unwrap { ($e:expr $(,)*) => { ... }; }
Available on crate feature
fmt
only.Expand description
Equivalent to Result::unwrap
, for use with const_format::Error
errors.
You can use this when you know for certain that no error will happen.
§Example
#![feature(const_mut_refs)]
use const_format::{StrWriter, unwrap, writec};
const CAP: usize = 11;
const TEXT: &str = {
const S: &StrWriter = &{
let mut writer = StrWriter::new([0; CAP]);
unwrap!(writec!(writer, "foo bar baz"));
writer
};
S.as_str_alt()
};
assert_eq!(TEXT, "foo bar baz")