#libc #print #dbg #std #macro #stdlib

libc-print

println! and eprintln! macros on libc without stdlib

21 releases

0.1.20 Jul 28, 2022
0.1.19 Mar 21, 2022
0.1.17 Aug 31, 2021
0.1.16 Feb 2, 2021
0.1.7 Dec 30, 2018

#113 in Rust patterns

Download history 414/week @ 2022-08-17 570/week @ 2022-08-24 458/week @ 2022-08-31 895/week @ 2022-09-07 751/week @ 2022-09-14 826/week @ 2022-09-21 913/week @ 2022-09-28 956/week @ 2022-10-05 1055/week @ 2022-10-12 957/week @ 2022-10-19 767/week @ 2022-10-26 1025/week @ 2022-11-02 859/week @ 2022-11-09 892/week @ 2022-11-16 518/week @ 2022-11-23 816/week @ 2022-11-30

3,269 downloads per month
Used in 13 crates (10 directly)

Apache-2.0 OR MIT

12KB
224 lines

no_std libc print/println/eprint/eprintln/dbg

Build Status docs.rs crates.io

Implements println!, eprintln! and dbg! on 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).

By default this crate provides libc_-prefixed macros, but also allows consumers to import macros with the same name as the stdlib printing macros via the std_name module.

Usage

Exactly as you'd use println!, eprintln! and dbg!.

#![no_std]

// 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);

Dependencies

~35KB