PackageTrack
Sign in Get early access

condtype

Choose types at compile-time via boolean constants.

1.3.0 11M downloads/mo #2879 most downloaded on crates.io nvzqz/condtype

What this package is like to depend on

Last release 3 years ago

no release in 18 months

Ships fairly regularly

a new release about every 2 months

Nearly every release is documented

notes for 4 of 4 stable releases

Nothing withdrawn

no release was ever pulled

3 years old

4 releases · first in 2023

0 releases in the last 12 months

see the full history below

Release timeline

4 releases · Apr 2023 to Aug 2023
2024 2025 2026
Release Pre-release

Releases

latest 4
  1. 1.3.0 20 Aug 2023
    Release notes

    Adds num module containing conditional aliases to numeric types.

    use std::fs::File;
    use condtype::num::Usize64;
    
    fn handle_throughput(bytes: Usize64) {
        // ...
    }
    
    // usize
    let s: &str = // ...
    handle_throughput(s.len() as Usize64);
    
    // u64
    let f: File = // ...
    handle_throughput(f.metadata()?.len() as Usize64);
    Open source →
    Release notes

    Added

    • num module containing conditional aliases to numeric types.
    Open source →
  2. 1.2.0 09 May 2023
    Release notes

    Adds if let pattern matching to the condval! macro.

    const STR: Option<&str> = // ...
    
    let val = condval!(if let Some(str) = STR {
        str.to_uppercase()
    } else {
        42
    });
    Open source →
    Release notes

    Added

    • if let pattern matching in [condval!].
    Open source →
  3. 1.1.0 25 Apr 2023
    Release notes

    Introduces the condval! macro to instantiate a conditionally-typed value.

    Attempting to return different types from if/else is not normally possible since both branches must produce the same type:

    let val = if true { "hello" } else { 42 };

    This macro enables returning different types by making the type be conditional on a const bool:

    use condtype::condval;
    
    let val: &str = condval!(if true { "hello" } else { 42 });
    let val: i32 = condval!(if false { "hello" } else { 42 });
    Open source →
    Release notes

    Added

    • [condval!] macro to construct [conditionally-typed][CondType] values.
    Open source →
  4. 1.0.0 18 Apr 2023
    Release notes

    Introduces the CondType type alias.

    use condtype::CondType;
    
    let str: CondType<true,  &str, i32> = "hello";
    let int: CondType<false, &str, i32> = 42;

    This can also be used with !Sized types:

    let str: &CondType<true, str, [u8]> = "world";
    Open source →
    Release notes

    Added

    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive