/*
Formatln! = format! + platform specific newline
https://internals.rust-lang.org/t/formatln-format-platform-specific-newline/13798
*/
fn codeOriginal()
{
let mut s = String::new();
let _ = writeln!
(
&mut s
, "{}"
, 5
);
}
/*
Formatln! = format! + platform specific newline
https://internals.rust-lang.org/t/formatln-format-platform-specific-newline/13798
*/
fn codeRevised()
{
/*
Use Trait std::fmt::Write ( Formatting Trait )
*/
use std::fmt::Write;
/*
Allocate String Object (s)
*/
let mut s = String::new();
/*
write formatted string into string object
*/
writeln!
(
&mut s
, "{}"
, 5
);
/*
println object s
*/
println!
(
"{}"
, s
);
//drop allocated object s
drop(s);
}
fn main()
{
codeRevised();
}