Commit Graph

7 Commits

Author SHA1 Message Date
Christopher Serr
02021fba24
Conditionally compile in Arc (#140)
Apparently the latest release of `bytemuck` doesn't compile on some of
the targets that it used to because it uses `Arc`. `Arc` is not a type
that exists on every target, because not every targets supports atomics.
2022-11-05 07:00:40 -06:00
zachs18
09dd2ffd68
Add cast_{arc,rc} (and slice and try), and {wrap,peel}_{arc,rc}. (#132)
* Add `allocation::{try_,}cast_{arc,rc}`, and add `{wrap,peel}_{arc,rc}` to `TransparentWrapperAlloc`.

* Avoid intermediate slice reference in `try_cast_slice_{arc,rc}`.

* remove `unsafe` block; run `cargo +nightly fmt` (ignoring files I didn't modify)

* Make `cast_rc` (etc) have the same bounds as `cast_mut`, due to the existence of `Rc::get_mut_unchecked`.
2022-09-01 17:23:28 -06:00
Waffle Maybe
331762b014
run cargo fmt (#120) 2022-07-24 09:27:49 -06:00
Waffle Maybe
0fe2b2c568
Add {wrap,peel}_box functions to TransparentWrapperAlloc (#119)
* Add `{wrap,peel}_box` functions to `TransparentWrapperAlloc`

* Add tests for `{wrap,peel}_box`
2022-07-23 21:09:32 -06:00
Edward
abe55e525e
feat: add TransparentWrapperAlloc trait (#111)
* feat: add TransparentWrapperAlloc trait

* implements wrap_vec and peel_vec

* fix: review comments

* remote asserts as they don't do anything
* avoid issue with stacked borrows
2022-06-28 17:55:31 -06:00
Lokathor
99ecb1f6cb rename "unwrap" to "peel". 2021-06-10 14:05:15 -06:00
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