Crates.io | truncating-arraystring |
lib.rs | truncating-arraystring |
version | 0.1.0 |
source | src |
created_at | 2023-02-08 17:00:57.133827 |
updated_at | 2023-02-08 17:00:57.133827 |
description | ArrayString wrapper with truncating Write |
homepage | |
repository | https://github.com/yuryshulaev/truncating-arraystring |
max_upload_size | |
id | 779976 |
size | 4,128 |
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");
}