Macro devela::os_println
source · macro_rules! os_println { () => { ... }; ($str:literal) => { ... }; ($($str:literal),+ $(,)?) => { ... }; ($buf:ident = $len:literal) => { ... }; ($buf:ident, $($args:tt)*) => { ... }; ($buf:ident = $len:literal, $($args:tt)*) => { ... }; ($expr:expr) => { ... }; ($($expr:expr),+ $(,)?) => { ... }; }
Available on (crate features
std
or linux_unsafe
) and crate feature depend
and crate feature text
only.Expand description
Prints to the standard output, with a newline.
Leverages linux_println
, format_buf
and str_concat
.
Usage is similar but not equal to std::
println!
.
Examples
use devela::os::{ansi, os_println};
os_println!(); // prints a newline (1st arm)
os_println!("hello world! 2nd arm"); // one literal
os_println!("hello", " world! ", 3_i32, 'r', "d arm"); // many literals
os_println!(buf_a=30); // create a buffer of some byte lenght (4th arm)
os_println!(buf_a, "hello world! {}th arm", 5); // formatted print using the buffer
os_println!(buf_b=20, "hello world! {}th arm", 6);// create a buffer and print
os_println!(&format!["{} {}! {}th arm", "hello", "world", 7]); // one &str expresion
os_println!(ansi![red], "hello", &format!["{}! {}th arm", "world", 8]); // many &str expressions
Output:
hello world! 2nd arm
hello world! 3rd arm
hello world! 5th arm
hello world! 6th arm
hello world! 7th arm
hello world! 8th arm
Error Handling
If the write fails, it prints an error message and exits with status code 10.