| Crates.io | swrite |
| lib.rs | swrite |
| version | 0.1.0 |
| created_at | 2023-04-06 16:57:15.107736+00 |
| updated_at | 2023-04-08 20:00:31.82016+00 |
| description | Infallible alternatives to write! and writeln! for Strings |
| homepage | https://github.com/rusticstuff/swrite |
| repository | https://github.com/rusticstuff/swrite |
| max_upload_size | |
| id | 832356 |
| size | 21,118 |
swrite is a tiny Rust crate providing the swrite! and swriteln! macros as
infallible alternatives to write! and writeln! for Strings. This is safe because
writing to a String never returns Err(_).
The implementation uses the SWrite trait. It is implemented for String.
With the osstring feature is enabled, it is also implemented for std::ffi::OsString.
Minimum Supported Rust Version (MSRV):
osstring feature (default): 1.30.0osstring feature: 1.64.0In Cargo.toml:
[dependencies]
swrite = "0.1.0"
In your Rust code:
use swrite::{SWrite, swrite, swriteln};
Using swrite! and swriteln! with a String:
use swrite::{SWrite, swrite, swriteln};
let mut s = String::new();
swrite!(s, "Hello, {}! ", "world");
swriteln!(s, "The answer is {}.", 42);
println!("{}", s);
Output:
Hello, world! The answer is 42.
This project is dual-licensed under Apache 2.0 and MIT licenses.