Registry / utility / phantom-type

phantom-type

JSON →
library0.5.2rscratesunverified

A PhantomData analog which prevents 'parameter is never used' error, but does not produce any restrictions in contrast with PhantomData.

# Cargo.toml [dependencies] phantom-type = "0.5.2"
INSTALL
IMPORT
SIG · PHANTOM-TYPE
P
phantom-type
utilityrustv0.5.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PhantomType
use phantom_type::PhantomType;

Uses PhantomType to avoid unused parameter warnings without adding restrictions.

use phantom_type::PhantomType; struct MyStruct<T> { value: i32, _marker: PhantomType<T>, } fn main() { let s = MyStruct::<String> { value: 42, _marker: PhantomType }; println!("{}", s.value); }
Debug
Known issues
gotchaPhantomType does not enforce any ownership or lifetime constraints unlike PhantomData.
fix
Use PhantomData if you need variance or drop check restrictions.
affects: >=0.5.0
Upgrade
Version history
0.5.2latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
phantom-type — cargo add phantom-type · libregistry