Skip to main content

index_of

Function index_of 

Source
pub fn index_of(spec: &'static Spec) -> usize
Expand description

Where in COMMANDS this spec is.

Every &'static Spec a caller can hold came out of lookup and therefore points into that array, so its position is the distance from the front measured in whole Specs. That is arithmetic on two addresses and not a search, which is the point: a per command counter has to be reachable from the spec the dispatcher is already holding without walking the table a second time.

A spec from somewhere else would answer nonsense, which is why this takes a &'static Spec rather than a &Spec: the only 'static ones are in the table.