#immutability #reference #pure #mutable #ref

pure_ref

A library for making immutable references only

4 releases

0.1.3 Jun 14, 2023
0.1.2 Jun 8, 2023
0.1.1 Jun 8, 2023
0.1.0 Jun 7, 2023

#29 in #ref

MIT license

3KB

The purspose of this library is to provide a way to take a reference to a potentionally mutable variable. Potentially mutable meaning it could be mutable in a struct.

use pure_ref::Pure;

let pure = Pure::new(10);
let borrowed = pure.borrowed();
// or `let borrowed = *pure;`
assert_eq!(*borrowed, 10);

No runtime deps