[−][src]Macro const_format::unwrap
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, strwriter_as_str, unwrap, writec}; const CAP: usize = 11; // Defined this function as a workaround for mutable references not // being allowed in `const`ants. const fn foo() -> StrWriter<[u8; CAP]> { let mut writer = StrWriter::new([0; CAP]); unwrap!(writec!(writer, "foo bar baz")); writer } const TEXT: &str = strwriter_as_str!(&foo()); assert_eq!(TEXT, "foo bar baz")