Crates.io | deki |
lib.rs | deki |
version | 0.1.1 |
source | src |
created_at | 2024-11-12 07:35:01.017862 |
updated_at | 2024-11-12 20:07:50.514996 |
description | A collection of crates, functions and renames tailored to myself! |
homepage | |
repository | https://github.com/dekirisu/deki-rs/ |
max_upload_size | |
id | 1444613 |
size | 23,919 |
[!NOTE] This mainly exists so I can depend on it quick, easy and anywhere.
[!IMPORTANT] Since this crate doesn't have a specific purpose, it may change a lot between 'minor' versions. That said, I'll follow semantic versioning of course! ✨
PhantomData
alias Ghost
*
*
self
and sandwich
new
as Constructor
#[derive(Constructor)] struct AStruct{field:u32}
-> AStruct::new(2);
extension
as ext
#[ext(trait F32Ext)] impl f32 {fn plus(self,rhs:f32)->f32{self+rhs}}
-> 4.0.plus(4.0);
self
as derive_more
and drv
#[derive(drv::Deref)] struct AStruct(#[deref]u32);
#[hashable(..)]
= #[derive(PartialEq,Eq,Hash,Clone,Copy,..)]
#[serde(..)]
= #[derive(Serialize,Deserialize,Clone,..)]
#[serde_hash(..)]
= #[derive(Serialize,Deserialize,PartialEq,Eq,Hash,Clone,Copy,..)]
#[deref(..)]
= #[derive(drv::Deref,drv::DerefMut,..)]
Hash
derivator is small and therefore fine to be copied!Syncable
for anything implementing 'static+Send+Sync
DefaultClear
for anything implementing Default
, id adds .clear()
to set it back to defaultLerpable
for any type with necessary maths to perform linear interpolation
3.0.lerp(4.0,0.1)
or any future type you impl maths forLerpableDeref
for any type that derefs to a type with necessary maths to perform linear interpolation
#[deref] struct AStruct(#[deref]f32);
-> AStruct(3.0).lerp(AStruct(4.0),0.1)
f32
by .smooth()
to apply cheap ease-in and -out (smooth-step) if within 0..=1f32
by .clamp_unit()
= .clamp(0.0,1.0)
Ramge<T>
& RangeInclusive<T>
by .add(T)
to offset itqonst!
(quick const): set a type and a value, name is automatically set to the type name in uppercaseself
as random
Vec
by .random()
*
(modified) as approx
f32
by .{operation}_ca
(ca = circa (latin))A struct with PhantomData
:
#[derive(Constructor)]
pub struct AStruct<T>(u32,#[new(default)]Ghost<T>)
// Construct somewhere:
AStruct::<String>::new(3);
Quick smooth interpolation of a struct with a f32:
#[deref(Constructor,Clone)]
struct AStruct {a:u32,#[deref]b:f32}
// run:
let from = AStruct::new(0,0.);
let to = AStruct::new(0,0.);
from.lerp(to,progress.smooth())