[−][src]Type Definition oceanpkg::drop::license::spdx::Map
type Map<A> = [A; 374];
A fixed-size array for indexing with a SpdxLicense
casted to usize
.
See also SpdxLicense::COUNT
.
This is a good example of flexible management of SpdxLicense
values that
allows for indexing without bounds checks (via as usize
casts) for free.
SemVer Compatibility: Like SpdxLicense::COUNT
, by just being
dependent on this value, the array size is allowed to change between
otherwise API-compatible versions.
Examples
Despite array indexing having bounds checks, the optimizer knows that
indexing with SpdxLicense
will never go out of bounds, giving us simple
and fast arithmetic for lookups.
use linfo::spdx::{Map, SpdxLicense}; let map: Map<&str> = [ // *a lot* of elements per license ]; let license = SpdxLicense::Mit; println!("map value is: {}", map[license as usize]);