Expand description
Implements println!
, eprintln!
and dbg!
on top of the libc
crate without requiring
the use of an allocator.
Allows you to use these macros in a #![no_std] context, or in a situation where the traditional Rust streams might not be available (ie: at process shutdown time).
libc_writeln
and libc_ewriteln
are provided for cases where you may not wish
to pull in the overhead of the formatter code and simply wish to print C-style strings.
§Usage
Exactly as you’d use println!
, eprintln!
and dbg!
.
// Use the default `libc_`-prefixed macros:
libc_println!("Hello {}!", "stdout");
libc_eprintln!("Hello {}!", "stderr");
let a = 2;
let b = libc_dbg!(a * 2) + 1;
assert_eq!(b, 5);
Or you can import aliases to std
names:
use libc_print::std_name::{println, eprintln, dbg};
println!("Hello {}!", "stdout");
eprintln!("Hello {}!", "stderr");
let a = 2;
let b = dbg!(a * 2) + 1;
assert_eq!(b, 5);
Modules§
- std_
name - This package contains the
libc_print
macros, but using the stdlib names such asprintln!
,print!
, etc.
Macros§
- libc_
dbg - Prints and returns the value of a given expression for quick and dirty debugging.
- libc_
eprint - Macro for printing to the standard error.
- libc_
eprintln - Macro for printing to the standard error, with a newline.
- libc_
ewrite - Macro for printing a static string to the standard error.
- libc_
ewriteln - Macro for printing a static string to the standard error, with a newline.
- libc_
print - Macro for printing to the standard output.
- libc_
println - Macro for printing to the standard output, with a newline.
- libc_
write - Macro for printing a static string to the standard output.
- libc_
writeln - Macro for printing a static string to the standard output, with a newline.