| Crates.io | libc-print |
| lib.rs | libc-print |
| version | 0.1.23 |
| created_at | 2018-12-30 06:10:36.259312+00 |
| updated_at | 2024-04-16 17:29:27.141879+00 |
| description | println! and eprintln! macros on libc without stdlib |
| homepage | |
| repository | https://github.com/mmastrac/rust-libc-print |
| max_upload_size | |
| id | 104529 |
| size | 26,097 |
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.
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);