Crate fundamental_data_type
source ·Expand description
Fundamental data types and type constructors, like Single, Pair, Many.
§Module :: fundamental_data_type
A collection of derive macros designed to enhance STD.
§To add to your project
cargo add fundamental_data_type
§Try out from the repository
git clone https://github.com/Wandalen/wTools
cd wTools
cd examples/fundamental_data_type_trivial
cargo run
Modules§
- Dependencies.
- Exposed namespace of the module.
- Orphan namespace of the module.
- Prelude to use essentials:
use my_module::prelude::*
. - Protected namespace of the module.
- Types, which are extension of std.
Macros§
- Variadic constructor.
Enums§
- The
ParseError
enum is a collection of all the possible reasons an enum can fail to parse from a string.
Traits§
- The addition operator
+
. - The addition assignment operator
+=
. - AsStaticRefDeprecatedA cheap reference-to-reference conversion. Used to convert a value to a reference value with
'static
lifetime within generic code. - The division operator
/
. - The division assignment operator
/=
. - A trait for capturing the number of variants in Enum. This trait can be autoderived by
strum_macros
. - Associates additional pieces of information with an Enum. This can be autoimplemented by deriving
EnumMessage
and annotating your variants with#[strum(message="...")]
. EnumProperty
is a trait that makes it possible to store additional information with enum variants. This trait is designed to be used with the macro of the same name in thestrum_macros
crate. Currently, the only string literals are supported in attributes, the other methods will be implemented as additional attribute types become stabilized.Error
is a trait representing the basic expectations for error values, i.e., values of typeE
inResult<T, E>
.- Constructor without arguments. Alias of Default.
- Constructor with single argument.
- Constructor with two arguments.
- Constructor with three arguments.
- Used for indexing operations (
container[index]
) in immutable contexts. - Used for indexing operations (
container[index]
) in mutable contexts. - value-to-value conversion that consumes the input value. Change left and rught, but keep semantic of `From_1``.
- This trait designates that an
Enum
can be iterated over. It can be auto generated usingstrum_macros
on your behalf. - Conversion into an
Iterator
. - The multiplication operator
*
. - The multiplication assignment operator
*=
. - The unary logical negation operator
!
. - The subtraction operator
-
. - The subtraction assignment operator
-=
. - Trait to represent types that can be created by summing up an iterator.
- An attempted conversion that consumes
self
, which may or may not be expensive. - A trait for retrieving the names of each variant in Enum. This trait can be autoderived by
strum_macros
.
Functions§
- Clone boxed dyn.
Attribute Macros§
- Derive macro to generate former for a structure. Former is variation of Builder Pattern.
Derive Macros§
- What
#[derive(Add)]
generates - What
#[derive(AddAssign)]
generates - Derive macro to implement AsMut when-ever it’s possible to do automatically.
- Derive macro to implement AsRef when-ever it’s possible to do automatically.
- Converts enum variants to
&'static str
. - What
#[derive(Constructor)]
generates - Derive macro to implement Deref when-ever it’s possible to do automatically.
- Derive macro to implement Deref when-ever it’s possible to do automatically.
- What
#[derive(Mul)]
generates - What
#[derive(MulAssign)]
generates - Add a constant
usize
equal to the number of variants. - Generate a new type with only the discriminant names.
- Generated
is_*()
methods for each variant. E.g.Color.is_red()
. - Creates a new type that iterates of the variants of an enum.
- Add a verbose message to an enum variant.
- Add custom properties to enum variants.
- Converts strings to enum variants based on their name.
- Generated
try_as_*()
methods for all tuple-style variants. E.g.Message.try_as_write()
. - Implements
Strum::VariantNames
which adds an associated constantVARIANTS
which is an array of discriminant names. - Using
#[derive(Error)]
- Provides an automatic
From
implementation for struct wrapping a single value. - Alias for derive
From
. Provides an automaticFrom
implementation for struct wrapping a single value. - Add a function to enum that allows accessing variants by its discriminant
- What
#[derive(Index)]
generates - What
#[derive(IndexMut)]
generates - Derive macro to implement From converting outer type into inner when-ever it’s possible to do automatically.
- Using
#[derive(IntoIterator)]
- Implements
From<MyEnum> for &'static str
on an enum. - What
#[derive(IsVariant)]
generates - What
#[derive(Mul)]
generates - What
#[derive(MulAssign)]
generates - What
#[derive(Not)]
generates - What
#[derive(Add)]
generates - What
#[derive(AddAssign)]
generates - Using
#[derive(Sum)]
- implements
std::string::ToString
on an enum - What
#[derive(TryInto)]
generates - What
#[derive(Unwrap)]
generates - Derive macro to implement default constructors
From_0
,From_1
,From_2
,From_3
.