swrite
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):
- Without the
osstringfeature (default): 1.30.0 - With the
osstringfeature: 1.64.0
Usage
In Cargo.toml:
[]
= "0.0.1"
In your Rust code:
use ;
Examples
Using swrite! and swriteln! with a String:
use ;
let mut s = Stringnew;
swrite!;
swriteln!;
println!;
Output:
Hello, world! The answer is 42.
License
This project is dual-licensed under Apache 2.0 and MIT licenses.