bytemuck/tests
Luis Wirth 30a96066fa
[Feature] extend TransparentWrapper conversion functions (#58)
* update rustfmt.toml

replace `merge_imports = true` (deprecated) with `imports_granularity = "Crate"`

* run `cargo +nightly fmt`

* rewrite docs and rename `Wrapped` to `Inner`

rewriting some docs for conciseness

rename `Wrapped` to `Inner`, because it's hard to visually differentiate between
`Wrapper` and `Wrapped`

* impl missing `TransparentWrapper::wrap_{}` fns

Implement 3 new wrapping functions on `TransparentWrapper` providing new
conversions.

- `TransparentWrapper::wrap(s: Inner) -> Self`
- `TransparentWrapper::wrap_slice(s: &[Inner]) -> &[Self]`
- `TransparentWrapper::wrap_slice_mut(s: &mut [Inner]) -> &mut [Self]`

* impl `TransparentWrapper::unwrap_{}` fns

Implement counterparts to `TransparentWrapper::wrap_{}` functions
providing reverse conversions.

- `TransparentWrapper::unwrap(self) -> Inner`
- `TransparentWrapper::unwrap_ref(&self) -> &Inner`
- `TransparentWrapper::unwrap_mut(&mut self) -> &mut Inner`
- `TransparentWrapper::unwrap_slice(s: &[Self]) -> &[Inner]`
- `TransparentWrapper::unwrap_slice_mut(s: &mut [Self]) -> &mut [Inner]`

* add `TransparentWrapper` UB test

This test is only for MIRI to check all trait functions on
`TransparentWrapper` if they cause any UB.
The output of the functions is not checked.

* small `TransparentWrapper` doc adjustments

* change fn signature on `TransparentWrapper`

Methods on `TransparentWrapper` trait are now associated functions.
They now take `Self` instead of `self` as argument)

- `TransparentWrapper::unwrap(s: Self)`
- `TransparentWrapper::unwrap_ref(s: &Self)`
- `TransparentWrapper::unwrap_mut(s: &mut Self)`
2021-03-28 23:11:13 -06:00
..
cast_slice_tests.rs [Feature] extend TransparentWrapper conversion functions (#58) 2021-03-28 23:11:13 -06:00
derive.rs [Feature] extend TransparentWrapper conversion functions (#58) 2021-03-28 23:11:13 -06:00
doc_tests.rs Duplicate the doctests for the sake of miri 2020-01-11 08:01:58 -08:00
offset_of_tests.rs update offset_of to have 2-arg and 3-arg versions. 2020-07-23 20:21:09 -06:00
std_tests.rs Prevent try_zeroed_box<T>() from reserving size_of<T>() space on the stack. (#43) 2020-10-21 14:11:09 -06:00
transparent.rs [Feature] extend TransparentWrapper conversion functions (#58) 2021-03-28 23:11:13 -06:00