Skip to content

Commit

Permalink
Extending conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheyca committed Mar 9, 2024
1 parent 87605de commit 990ba74
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
members = ["internal/ruchei-sample"]

[workspace.package]
version = "0.0.67" # ad7038ef3b571dc133c108e14e6bb0f8cdcd812d and earlier have invalid versions
version = "0.0.68" # ad7038ef3b571dc133c108e14e6bb0f8cdcd812d and earlier have invalid versions
edition = "2021"
publish = true
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Utilities for working with many streams
#![deny(unsafe_code)]
#![forbid(unsafe_code)]

extern crate self as ruchei;

Expand Down
33 changes: 33 additions & 0 deletions src/pinned_extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@ impl<S, R> Extending<S, R> {
pub fn new(incoming: R, inner: S) -> Self {
Self { incoming, inner }
}

pub fn as_pin_mut(self: Pin<&mut Self>) -> Pin<&mut S> {
self.project().inner
}

pub fn into_inner(self) -> S {
self.inner
}

pub fn incoming_pin_mut(self: Pin<&mut Self>) -> Pin<&mut R> {
self.project().incoming
}

pub fn incoming(&self) -> &R {
&self.incoming
}

pub fn incoming_mut(&mut self) -> &mut R {
&mut self.incoming
}

pub fn into_incoming(self) -> R {
self.incoming
}
}

impl<S, R> AsRef<S> for Extending<S, R> {
Expand Down Expand Up @@ -116,3 +140,12 @@ impl<R> ExteningExt for R {
Extending::new(self, inner)
}
}

impl<S: Default, R> From<R> for Extending<S, R> {
fn from(incoming: R) -> Self {
Self {
incoming,
inner: Default::default(),
}
}
}

0 comments on commit 990ba74

Please sign in to comment.