displaydoc-lite

Crates.iodisplaydoc-lite
lib.rsdisplaydoc-lite
version0.1.3
sourcesrc
created_at2021-02-07 16:17:08.194864
updated_at2021-02-08 18:00:54.439704
descriptionImplement the Display trait using your standard doc comments.
homepagehttps://github.com/Stupremee/displaydoc-lite
repositoryhttps://github.com/Stupremee/displaydoc-lite
max_upload_size
id351981
size23,748
Justus K (Stupremee)

documentation

https://docs.rs/displaydoc-lite

README

displaydoc-lite

Crates.io Documentation

Implement the Display trait using your standard doc comments.

This crate is a lite version of the popular crate displaydoc. It provides the same functionality but using a declarative macro instead and not depending on syn or quote.

This crate is also usable in no_std environments. No additional features are required for that.

Note: displaydoc-lite still has a proc-macro as a dependency, but it's very tiny and doesn't have any dependencies.

Example

use displaydoc_lite::displaydoc;

displaydoc! {
    #[derive(Debug)]
    pub enum DataStoreError {
        /// data store disconnected: {_0}
        Disconnect(io::Error),
        /// the data for key `{_0}` is not available
        Redaction(String),
        /// invalid header (expected {expected}, found {found})
        InvalidHeader {
            expected: String,
            found: String,
        },
        /// unknown data store error
        Unknown,
    }
}

Details

Listing of all supported syntax variants inside a {}:

  • {var} -> write!("{}", self.var)

  • {_0} -> write!("{}", self.0)

  • {var:?} -> write!("{:?}", self.var)

  • {_0:?} -> write!("{:?}", self.0)

License

Licensed under either Apache License or the MIT license.

Commit count: 24

cargo fmt