Closed ltratt closed 6 years ago
Because we don't know the type of a TokId, we have to use traits and constraints. This led to lots ugliness like:
TokId: Clone + Copy + Debug + PartialEq + TryFrom<usize> + TryInto<usize>
This PR makes greater use of the num_traits crate. The above becomes:
TokId: PrimInt + Unsigned
This also allows us to ditch try_from, which still hasn't stabilised in Rust and which is on the laborious side. Things like:
u32::try_from(x).unwrap();
become:
x.to_u32().unwrap();
It's not a huge difference, but given that we also save on the trait constraints, it seems a worthwhile change.
Because we don't know the type of a TokId, we have to use traits and constraints. This led to lots ugliness like:
This PR makes greater use of the num_traits crate. The above becomes:
This also allows us to ditch try_from, which still hasn't stabilised in Rust and which is on the laborious side. Things like:
become:
It's not a huge difference, but given that we also save on the trait constraints, it seems a worthwhile change.