#named #traits #dogma

no-std dogma

Provides Named, MaybeNamed, Labeled, MaybeLabeled, Collection, and CollectionMut traits

9 releases

new 0.1.8 May 9, 2025
0.1.7 May 7, 2025
0.1.5 Apr 27, 2025
0.1.1 Oct 15, 2024
0.0.0 Aug 3, 2020

#197 in Data structures

Download history 81/week @ 2025-01-17 30/week @ 2025-01-24 15/week @ 2025-01-31 34/week @ 2025-02-07 217/week @ 2025-02-14 205/week @ 2025-02-21 163/week @ 2025-02-28 96/week @ 2025-03-07 53/week @ 2025-03-14 68/week @ 2025-03-21 114/week @ 2025-03-28 100/week @ 2025-04-04 209/week @ 2025-04-11 325/week @ 2025-04-18 716/week @ 2025-04-25 325/week @ 2025-05-02

1,604 downloads per month
Used in 61 crates (33 directly)

Unlicense

30KB
693 lines

Dogma.rs

License Compatibility Package Documentation

Provides the Named, MaybeNamed, Labeled, MaybeLabeled, Collection, and CollectionMut traits for Rust.

✨ Features

  • Supports opting out of any feature using comprehensive feature flags.
  • Adheres to the Rust API Guidelines in its naming conventions.
  • 100% free and unencumbered public domain software.

🛠️ Prerequisites

⬇️ Installation

Installation via Cargo

cargo add dogma

Installation in Cargo.toml (with all features enabled)

[dependencies]
dogma = "0.1"

Installation in Cargo.toml (with only specific features enabled)

[dependencies]
dogma = { version = "0.1", default-features = false, features = ["traits"] }

👉 Examples

Importing the library

use dogma::*;

Using the Named trait

use dogma::traits::Named;
use std::borrow::Cow;

struct Person {
    pub first_name: String,
    pub last_name: String,
}

impl Named for Person {
    fn name(&self) -> Cow<str> {
        format!("{} {}", self.first_name, self.last_name).into()
    }
}

Using the MaybeNamed trait

use dogma::traits::MaybeNamed;
use std::borrow::Cow;

struct UserProfile {
    pub id: u64,
    pub display_name: Option<String>,
}

impl MaybeNamed for UserProfile {
    fn name(&self) -> Option<Cow<str>> {
        self.display_name.as_ref().map(Cow::from)
    }
}

📚 Reference

https://docs.rs/dogma/

Traits

Integrations

👨‍💻 Development

git clone https://github.com/dogmatists/dogma.rs.git

Share on X Share on Reddit Share on Hacker News Share on Facebook Share on LinkedIn

Dependencies

~0.9–1.8MB
~34K SLoC