24 releases

new 0.1.23 Apr 16, 2024
0.1.22 Sep 26, 2023
0.1.21 Feb 25, 2023
0.1.20 Jul 28, 2022
0.1.7 Dec 30, 2018

#163 in Rust patterns

Download history 1238/week @ 2023-12-23 801/week @ 2023-12-30 1484/week @ 2024-01-06 1834/week @ 2024-01-13 1532/week @ 2024-01-20 1000/week @ 2024-01-27 1164/week @ 2024-02-03 965/week @ 2024-02-10 1015/week @ 2024-02-17 1551/week @ 2024-02-24 1473/week @ 2024-03-02 1391/week @ 2024-03-09 1478/week @ 2024-03-16 1249/week @ 2024-03-23 1490/week @ 2024-03-30 1095/week @ 2024-04-06

5,450 downloads per month
Used in 37 crates (18 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

~42KB