As of 014adb91642c6fea6ad273ebadb6437df79edc78, there are a lot of TODOs on this function, so it probably deserves its own issue:
/// TODO: rewrite this as a `TryFrom` implementation (see issue #85)
// - eliza, 03/09/2017
/// wait, possibly we should NOT do that. actually we should
/// almost certainly not do that. since this function is unsafe,
/// but `TryFrom` is not, and because this would be WAY generic.
// - eliza, 03/09/2017
/// TODO: is this general enough to move into util?
// - eliza, 03/09/2017
/// TODO: should this be refactored to return a `Result`?
// - eliza, 03/13/2017
/// TODO: can we ensure that the lifetime of the returned slice is the same
/// as the lifetime of the input byte slice, rather than inferred by
/// [`slice::from_raw_parts`]?
// - eliza, 03/13/2017
/// TODO: assert that `offset` is aligned on a `T`-sized boundary
// - eliza, 03/13/2017
/// TODO: do we want to assert that `offset` is less than the length of `data`
/// separately from asserting that the slice is long enough, so that
/// we can panic with different messages?
// - eliza, 03/13/2017
///
[x] ensure that the lifetime of the returned slice is the same as the lifetime of the input slice
[x] assert offset is aligned on a T-sized boundary
As of 014adb91642c6fea6ad273ebadb6437df79edc78, there are a lot of TODOs on this function, so it probably deserves its own issue:
offset
is aligned on aT
-sized boundaryoffset
is a valid offset intodata
Result
util
crate