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§

  • This package contains the libc_print macros, but using the stdlib names such as println!, print!, etc.

Macros§

  • Prints and returns the value of a given expression for quick and dirty debugging.
  • Macro for printing to the standard error.
  • Macro for printing to the standard error, with a newline.
  • Macro for printing a static string to the standard error.
  • Macro for printing a static string to the standard error, with a newline.
  • Macro for printing to the standard output.
  • Macro for printing to the standard output, with a newline.
  • Macro for printing a static string to the standard output.
  • Macro for printing a static string to the standard output, with a newline.