Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions inout/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Migrated from `generic-array` to `hybrid-array` ([#944])
- MSRV is bumped to 1.81 ([#1116])

### Added
- `InOut::into_out` and `InOutBufReserved::into_out` methods ([#1132])

[#944]: https://github.com/RustCrypto/utils/pull/944
[#1116]: https://github.com/RustCrypto/utils/pull/1116
[#1132]: https://github.com/RustCrypto/utils/pull/1132

## 0.1.3 (2022-03-31)
### Fixed
Expand Down
6 changes: 6 additions & 0 deletions inout/src/inout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ impl<'inp, 'out, T> InOut<'inp, 'out, T> {
unsafe { &mut *self.out_ptr }
}

/// Consume `self` and get mutable reference to the output value with lifetime `'out`.
#[inline(always)]
pub fn into_out(self) -> &'out mut T {
unsafe { &mut *self.out_ptr }
}

/// Convert `self` to a pair of raw input and output pointers.
#[inline(always)]
pub fn into_raw(self) -> (*const T, *mut T) {
Expand Down
2 changes: 1 addition & 1 deletion inout/src/inout_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl<'inp, 'out, T> InOutBuf<'inp, 'out, T> {
unsafe { slice::from_raw_parts_mut(self.out_ptr, self.len) }
}

/// Consume self and return output slice with lifetime `'a`.
/// Consume `self` and get output slice with lifetime `'out`.
#[inline(always)]
pub fn into_out(self) -> &'out mut [T] {
unsafe { slice::from_raw_parts_mut(self.out_ptr, self.len) }
Expand Down
6 changes: 6 additions & 0 deletions inout/src/reserved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ impl<'inp, 'out, T> InOutBufReserved<'inp, 'out, T> {
pub fn get_out<'a>(&'a mut self) -> &'a mut [T] {
unsafe { slice::from_raw_parts_mut(self.out_ptr, self.out_len) }
}

/// Consume `self` and get output slice with lifetime `'out`.
#[inline(always)]
pub fn into_out(self) -> &'out mut [T] {
unsafe { slice::from_raw_parts_mut(self.out_ptr, self.out_len) }
}
}

impl<'inp, 'out> InOutBufReserved<'inp, 'out, u8> {
Expand Down