Crate libc_print

Source
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 as println!, 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.