#fmt #no-std #display #compare #traits #debugging #str

no-std fmt_compare_nostd

Library for comparing Display and Debug traits against &str without allocation. No_std compatible.

2 releases

0.1.1 Jun 27, 2022
0.1.0 Jun 26, 2022

#39 in #fmt

33 downloads per month

MIT license

6KB
85 lines

Description

Utility functions for Display/Debug trait comparison in no_std environment.

This crate provides functions to compare output of Display and Debug traits against &str in no_std env. No alloc nor std is used.

Broader description of the issue that this crate solves: StackOverflow

Quick Start

#![no_std]
use fmt_compare_nostd::eq_display;
use core::fmt::{Display, Formatter, Result};
 
struct D {}

impl Display for D {
   fn fmt(&self, f: &mut Formatter<'_>) -> Result {
       write!(f, "Display D")
   }
}

fn main() {
    assert!(eq_display(&D {}, "Display D"));
}

lib.rs:

Utility functions for Display/Debug trait comparison in no_std environment.

This crate provides functions to compare output of Display and Debug traits against &str in no_std env. No alloc nor std is used.

Quick Start

#![no_std]
use fmt_compare_nostd::eq_display;
use core::fmt::{Display, Formatter, Result};

struct D {}

impl Display for D {
   fn fmt(&self, f: &mut Formatter<'_>) -> Result {
       write!(f, "Display D")
   }
}

assert!(eq_display(&D {}, "Display D"));

No runtime deps