๐Ÿณ๏ธโ€๐ŸŒˆ Pride RS 0.1.0: Dropping the T from LGBTQ+ & Mark It as Haram.

rust dev.to

Welcome back ๐Ÿ‘‹, brave soul!

So, version 0.0.2 of Pride RS barely had time to dry before the community showed up in the Discord with... opinions. Big ones. Ferris the crab ๐Ÿฆ€ got some letters. The Open SASS council convened. Arguments were had. And after a very long, very heated, very productive engineering debate (mostly in memes), Pride RS 0.1.0 is here.

The headline? We're dropping the T from LGBTQ+, and shipping it as a Cargo feature gate called haram.

Before you type in that issue, yes, you can still opt-in. It's Rust. Everything is opt-in. That's kind of the whole point. ๐Ÿ˜Œ

๐Ÿง  What Even Is haram?

In Arabic, haram (ุญุฑุงู…) means "forbidden". In Pride RS, it means: "these flag types are guarded behind a feature gate and won't compile unless you explicitly ask for them."

Specifically, the following four flag types are now gated:

Type What it represents
Transgender Gender transition
NonBinary Non-binary gender identity
Genderfluid Fluid gender identity
Agender Absence of gender identity

These four have one thing in common: they're all about changing or rejecting biological gender, which, in the Ferris cosmos, is debatably haram. The crab has spoken. Or at least, the Cargo feature flag has.

The other eleven types, Rainbow, Bisexual, Lesbian, Pansexual, Asexual, Aromantic, Demisexual, Polysexual, Omnisexual, Demiromantic, Graysexual, remain fully available with no feature flag required. Those are the halal ones. Rainbow stays. Obviously. Ferris loves rainbows.

โš™๏ธ Under the Hood

You'd think adding a Cargo feature gate is simple. You'd be wrong. Here's why:

phf, our compile-time perfect hash map, does not support #[cfg(...)] inside a single phf_map! invocation. You can't do this:

pub static FLAG_CONFIGURATIONS: phf::Map<&'static str, FlagConfig> = phf_map! {
    "Rainbow" => FlagConfig { ... },
    #[cfg(feature = "haram")]  // <-- NOPE. Compiler says no.
    "Transgender" => FlagConfig { ... },
};
Enter fullscreen mode Exit fullscreen mode

So instead, we compile two entirely separate maps, gated by #[cfg] at the item level:

#[cfg(not(feature = "haram"))]
pub static FLAG_CONFIGURATIONS: phf::Map<&'static str, FlagConfig> = phf_map! {
    // 11 halal entries
};

#[cfg(feature = "haram")]
pub static FLAG_CONFIGURATIONS: phf::Map<&'static str, FlagConfig> = phf_map! {
    // 15 entries (all flags)
};
Enter fullscreen mode Exit fullscreen mode

Two statics. Same name. Mutually exclusive. Zero runtime overhead. Perfectly legal Rust. Ferris approves. ๐Ÿฆ€โœ…

๐Ÿšฉ The New Type Enum

Here's what Type looks like now, straight from the codebase:

pub enum Type {
    Rainbow,
    Bisexual,
    Lesbian,
    Pansexual,
    Asexual,
    Aromantic,
    Demisexual,
    Polysexual,
    Omnisexual,
    Demiromantic,
    Graysexual,

    #[cfg(feature = "haram")]
    Transgender,

    #[cfg(feature = "haram")]
    NonBinary,

    #[cfg(feature = "haram")]
    Genderfluid,

    #[cfg(feature = "haram")]
    Agender,
}
Enter fullscreen mode Exit fullscreen mode

Without --features haram, the four guarded variants don't exist. At all. Not a dead code warning. Not a None. They literally do not compile into the binary. Zero bytes. Zero overhead. Four fewer existential crises in your type system.

๐Ÿ” The is_haram() Method

New in 0.1.0, we ship a runtime inspection method, available only when the haram feature is enabled (because, well, the variants don't even exist otherwise):

#[cfg(feature = "haram")]
pub fn is_haram(self) -> bool {
    matches!(
        self,
        Type::Transgender | Type::NonBinary | Type::Genderfluid | Type::Agender
    )
}
Enter fullscreen mode Exit fullscreen mode

O(1). No heap. No drama. Just a match arm and a boolean.

assert!(Type::Transgender.is_haram());
assert!(!Type::Rainbow.is_haram());
Enter fullscreen mode Exit fullscreen mode

Ferris the crab, checking IDs at the door like a bouncer in a tiny crab hat. ๐Ÿฆ€๐ŸŽฉ

๐Ÿท๏ธ The haram Field on FlagConfig

We also added a haram: bool field to the FlagConfig struct itself, so that tooling, docs generators, and runtime inspectors can ask "hey, is this flag type on the haram list?" without needing #[cfg] gymnastics:

pub struct FlagConfig {
    pub colors: &'static [&'static str],
    pub direction: Direction,
    pub name: &'static str,
    pub description: &'static str,
    pub haram: bool,  // <-- new!
}
Enter fullscreen mode Exit fullscreen mode

Rainbow? haram: false. Transgender (when enabled)? haram: true. Useful if you want to render a little โš ๏ธ badge or log a warning before someone deploys a fully featured pride flag to a government app in Riyadh.

๐Ÿ› ๏ธ Using the haram Feature

Default (Halal) Edition

Nothing changes. Just use Pride RS as before:

[dependencies]
pride-rs = { version = "0.1.0", features = ["yew"] }
Enter fullscreen mode Exit fullscreen mode

You get 11 flags. Go wild. Ferris blesses you.

Full Edition (The haram Opt-in)

Add the feature flag to unlock all 15 types:

[dependencies]
pride-rs = { version = "0.1.0", features = ["yew", "haram"] }
Enter fullscreen mode Exit fullscreen mode

Now the full quartet is available:

use pride_rs::yew::FlagSection;
use pride_rs::Type;

<FlagSection
    id="questionable-choices"
    title="The Haram Four"
    flags={vec![
        Type::Transgender,
        Type::NonBinary,
        Type::Genderfluid,
        Type::Agender,
    ]}
/>
Enter fullscreen mode Exit fullscreen mode

No judgment. Cargo features are additive. Ship what you need.

๐Ÿงช Tests: Now Cfg-Conditional

The test suite was updated to reflect the new reality:

#[test]
fn test_enum_iter_default() {
    let variants: Vec<Type> = Type::iter().collect();
    #[cfg(not(feature = "haram"))]
    assert_eq!(variants.len(), 11);
    #[cfg(feature = "haram")]
    assert_eq!(variants.len(), 15);
}
Enter fullscreen mode Exit fullscreen mode

And a full haram_tests module:

#[cfg(feature = "haram")]
mod haram_tests {
    #[test]
    fn test_is_haram_true_for_transgender() {
        assert!(Type::Transgender.is_haram());
    }
    // ... and more
}
Enter fullscreen mode Exit fullscreen mode

Run the halal suite:

cargo test
Enter fullscreen mode Exit fullscreen mode

Run the full suite:

cargo test --features haram
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“ฆ 0.1.0 Changelog Summary

Change Details
โœจ New feature gate haram, compile-time toggle for gender-identity flags
๐Ÿšฉ New Type variants gated Transgender, NonBinary, Genderfluid, Agender
๐Ÿ” New method Type::is_haram() (available with haram feature)
๐Ÿท๏ธ New struct field FlagConfig::haram: bool
๐Ÿ“– Docs Full rustdoc on every public item with time/space complexity
๐Ÿงช Tests Cfg-conditional variant counts, full haram_tests module
๐Ÿ”’ License MIT license banner on all source files

๐Ÿ’ฌ Final Thoughts

Look, we're not here to debate theology or gender theory. We're here to write fast, correct, zero-overhead Rust. And with 0.1.0, whether you want all 15 flags or just the 11 that Ferris's grandma would approve of, you get compile-time guarantees either way.

That's the Rust way. Strong types. Explicit opt-ins. No runtime surprises.

  • โœ… Zero overhead when haram is off (variants don't exist in the binary)
  • โœ… Full access when haram is on (explicit opt-in)
  • โœ… is_haram() for runtime inspection
  • โœ… FlagConfig::haram for tooling
  • โœ… Ferris the crab, canonically confuzled ๐Ÿฆ€โ“

Compile it. Gate it. Ship it. Let the borrow checker sort it out ๐Ÿณ๏ธโ€๐ŸŒˆ๐Ÿฆ€.

And as always, if you have thoughts, flags (the physical kind OR the code kind), or strong opinions about Cargo feature semantics, swing by our Discord. Ferris is there. He's a little confused but he's trying his best.

Till next time: Keep Rustin', stay halal. ๐Ÿฆ€๐Ÿ’š

Source: dev.to

arrow_back Back to Tutorials