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 2023Releases
latest 4-
1.3.020 Aug 2023Release notes
Open source →Adds
nummodule 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);
-
1.2.009 May 2023Release notes
Open source →Adds
if letpattern matching to thecondval!macro.const STR: Option<&str> = // ... let val = condval!(if let Some(str) = STR { str.to_uppercase() } else { 42 });
-
1.1.025 Apr 2023Release notes
Open source →Introduces the
condval!macro to instantiate a conditionally-typed value.Attempting to return different types from
if/elseis 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
constbool:use condtype::condval; let val: &str = condval!(if true { "hello" } else { 42 }); let val: i32 = condval!(if false { "hello" } else { 42 });
Release notes
Open source →Added
- [
condval!] macro to construct [conditionally-typed][CondType] values.
- [
-
1.0.018 Apr 2023Release notes
Open source →Introduces the
CondTypetype alias.use condtype::CondType; let str: CondType<true, &str, i32> = "hello"; let int: CondType<false, &str, i32> = 42;
This can also be used with
!Sizedtypes:let str: &CondType<true, str, [u8]> = "world";
Release notes
Open source →Added
CondTypetype alias that is determined by a boolean condition, just likestd::conditional_tin C++.