Crates.io | unsaferef |
lib.rs | unsaferef |
version | 0.1.0 |
source | src |
created_at | 2024-09-28 19:54:36.437186 |
updated_at | 2024-09-28 19:54:36.437186 |
description | An unsafe reference without explicit lifetime |
homepage | https://crates.io/crates/unsaferef |
repository | https://github.com/ohkami-rs/unsaferef |
max_upload_size | |
id | 1390325 |
size | 10,242 |
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)
}
UnsafeRef
supports no-std::no-alloc
.
On alloc
feature ( default ), unsaferef additionally provides UnsafeCow
, an unsafe Clone-on-Write container without explicit lifetime.
unsaferef is licensed under MIT LICENSE ( LICENSE or https://opensource.org/licenses/MIT ).