#claim #object #ability #duplicate #cheaply #derive #context

no-std yukon

Provides trait for the ability to cheaply duplicate an object

3 releases

0.1.2 Dec 5, 2024
0.1.1 Dec 5, 2024
0.1.0 Dec 4, 2024
0.0.0 Dec 4, 2024

#960 in Rust patterns

Download history 325/week @ 2024-12-02 20/week @ 2024-12-09

345 downloads per month
Used in yukon_derive

MIT/Apache

10KB
126 lines

yukon

crates.io Docs Testing License: MIT

Provides trait for the ability to cheaply duplicate an object.


lib.rs:

Provides trait for the ability to cheaply duplicate an object.

Examples

Claim can be derived for structs that contain only fields that implement Claim themselves:

use yukon::Claim;

#[derive(Claim)]
struct Context {
    value: Arc<usize>,
}
#

Alternatively, Claim can be implemented manually:

#
#
impl Claim for Context {
    fn claim(&self) -> Self {
        Self {
            value: Arc::clone(&self.value),
        }
    }
}
#

References

This crate has been inspired by Claiming, auto and otherwise.

Dependencies

~105KB