Skip to content

Latest commit

 

History

History
15 lines (12 loc) · 444 Bytes

README.md

File metadata and controls

15 lines (12 loc) · 444 Bytes

truncating-arraystring

ArrayString wrapper with truncating Write.

use std::fmt::Write;
use truncating_arraystring::TruncatingArrayString;

fn main() {
    let mut buf = TruncatingArrayString::<5>::new();
    assert_eq!(write!(buf, "{}", "12"), Ok(()));
    assert_eq!(write!(buf, "{}", "3456789"), Err(std::fmt::Error));
    assert_eq!(&buf.0[..], "12345");
}