5 releases (3 breaking)

0.4.0 Sep 14, 2023
0.3.1 Sep 13, 2023
0.3.0 Sep 13, 2023
0.2.0 Sep 13, 2023
0.1.0 Sep 13, 2023

#1819 in Rust patterns

37 downloads per month
Used in hollywood

MIT/Apache

5KB

About

This crate defines a Linear<T> type. This is a type whose values can not be dropped and must be eventually consumed with the into_inner() method. Failing to do so will result in a panic or compile error.

Unlike Pin linear types can be moved and unlike ManuallyDrop linear types require to be eventually deconstructed unless they are forgotten with mem::forget().

Status

This crate started on a discussion on IRC. It does not implement pure linear-type theory as this would require language support. Consider it as proof-of-concept. It may have some use and should be safe (in the rust sense) to use. Improvements and PR's are welcome. This crate will be somewhat in flux before a 1.0 version is released.

Features

When this crates is compiled with the 'compile_error' feature flag then it will use the 'no-panic' crate to generate compile errors whenever Linear<T> will be dropped.

Please read https://github.com/dtolnay/no-panic#caveats for details.

Dependencies

~105KB