ref-extended

Crates.ioref-extended
lib.rsref-extended
version0.2.1
sourcesrc
created_at2022-12-07 05:31:17.310549
updated_at2022-12-08 13:27:13.835326
descriptionAchieve lifetime of value by shortening entire program lifetime
homepage
repositoryhttps://github.com/storycraft/ref-extended
max_upload_size
id731622
size5,620
storycraft (storycraft)

documentation

README

Ref Extended

Extends lifetime of reference to same as lifetime of value by shortening entire program lifetime

When it is useful?

  1. You are doing programming without heap allocation (such as embed programming), and don't want to use static.
  2. You run some diverging functions which exit process itself without returning.

Example

let mut a = 2_i32; // The lifetime of value itself(not reference) is 'static

// Safely extend lifetimes and abort after expression finish
ref_extended!(|&a| {
    identity::<&'static i32>(a); // This compiles
});

// Unreachable. Process abort
Commit count: 16

cargo fmt