#lifetime #enums #memory #data #no-std

no-std cloneless_cow

A greatly-reduced implementation of Cow that does not require T to be Clone but allows for storing either a reference or an owned instance for future needs of references to T

2 releases

0.1.1 Nov 17, 2024
0.1.0 Nov 17, 2024

#1709 in Data structures

Download history 116/week @ 2024-11-11 126/week @ 2024-11-18 9/week @ 2024-11-25 2/week @ 2024-12-02 17/week @ 2024-12-09

270 downloads per month
Used in 3 crates

MIT/Apache

7KB

Cloneless Cow

Allows for the storage of a reference or owned instance of a generic type T.

Features

  • Convenient storage of a reference or owned instance, even (and especially) for types that do not implement Clone
  • Able to access the instance reference via .as_ref()

Limitations

  • Impossible to clone T directly out of the instance or get back the owned T
    • This feature of Cow is also a limitation of Cow which this crate does not suffer from, as Cow requires T to implement the Clone trait when you may only want access to a reference of T

No runtime deps