#libc #print

libc-print

println! and eprintln! macros on libc without stdlib

23 releases

new 0.1.22 Sep 26, 2023
0.1.21 Feb 25, 2023
0.1.20 Jul 28, 2022
0.1.19 Mar 21, 2022
0.1.7 Dec 30, 2018

#531 in Rust patterns

Download history 369/week @ 2023-06-08 494/week @ 2023-06-15 476/week @ 2023-06-22 433/week @ 2023-06-29 528/week @ 2023-07-06 393/week @ 2023-07-13 563/week @ 2023-07-20 544/week @ 2023-07-27 827/week @ 2023-08-03 760/week @ 2023-08-10 428/week @ 2023-08-17 429/week @ 2023-08-24 334/week @ 2023-08-31 493/week @ 2023-09-07 638/week @ 2023-09-14 1220/week @ 2023-09-21

2,779 downloads per month
Used in 18 crates (15 directly)

Apache-2.0 OR MIT

13KB
241 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

~39KB