unsaferef

Crates.iounsaferef
lib.rsunsaferef
version0.1.0
sourcesrc
created_at2024-09-28 19:54:36.437186
updated_at2024-09-28 19:54:36.437186
descriptionAn unsafe reference without explicit lifetime
homepagehttps://crates.io/crates/unsaferef
repositoryhttps://github.com/ohkami-rs/unsaferef
max_upload_size
id1390325
size10,242
core (github:ohkami-rs:core)

documentation

https://docs.rs/unsaferef

README

unsaferef

An unsafe reference without explicit lifetime

License CI status crates.io

Example

use unsaferef::UnsafeRef;

fn main() {
    let data = String::from("Hello, world!");

    // SAFETY: `data` is alive as long as `r` is in use
    let r: UnsafeRef<String> = unsafe {
        UnsafeRef::new(&data)
    };

    assert_eq!(*r, "Hello, world!");

    drop(data)
}

no-std and cow

UnsafeRef supports no-std::no-alloc.

On alloc feature ( default ), unsaferef additionally provides UnsafeCow, an unsafe Clone-on-Write container without explicit lifetime.

License

unsaferef is licensed under MIT LICENSE ( LICENSE or https://opensource.org/licenses/MIT ).

Commit count: 14

cargo fmt