#display #derive #no-std

macro no-std description-macro

implementation detail of the description crate

3 releases (breaking)

0.3.0 Nov 2, 2024
0.2.0 Nov 1, 2024
0.1.0 Nov 1, 2024

#442 in #display

Download history 310/week @ 2024-10-28 87/week @ 2024-11-04

397 downloads per month
Used in description

MIT license

7KB
110 lines

derive(Description)

This library provides a trait and derive macro that is like std::fmt::Display, but using compile-time strings.

The library is fully no_std and no_alloc, and is meant to provide user-facing text for enum-like status messages without code bloat.

[dependencies]
description = "0.1.0"

Example

use description::Description;

#[derive(Description)]
enum ChargerStatus {
    #[description("Charger connected!")]
    Connected,

    #[description("Charger disconnected!")]
    Disconnected,
}

fn main() {
    let charger = ChargerStatus::Connected;

    println!("Charger notification: {}", charger.description());
}

Dependencies

~205–640KB
~15K SLoC