pub struct RcBiTransformer<T, U, R> { /* private fields */ }Expand description
RcBiTransformer - single-threaded bi-transformer wrapper
A single-threaded, clonable bi-transformer wrapper optimized for scenarios that require sharing without thread-safety overhead.
§Features
- Based on:
Rc<dyn Fn(T, U) -> R> - Ownership: Shared ownership via reference counting (non-atomic)
- Reusability: Can be called multiple times (each call consumes its inputs)
- Thread Safety: Not thread-safe (no
Send + Sync) - Clonable: Cheap cloning via
Rc::clone
§Author
Haixing Hu
Implementations§
Source§impl<T, U, R> RcBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
impl<T, U, R> RcBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
Sourcepub fn new<F>(f: F) -> Selfwhere
F: Fn(T, U) -> R + 'static,
pub fn new<F>(f: F) -> Selfwhere
F: Fn(T, U) -> R + 'static,
Creates a new bi-transformer.
Wraps the provided closure in the appropriate smart pointer type for this bi-transformer implementation.
Sourcepub fn new_with_name<F>(name: &str, f: F) -> Selfwhere
F: Fn(T, U) -> R + 'static,
pub fn new_with_name<F>(name: &str, f: F) -> Selfwhere
F: Fn(T, U) -> R + 'static,
Creates a new named bi-transformer.
Wraps the provided closure and assigns it a name, which is useful for debugging and logging purposes.
Sourcepub fn new_with_optional_name<F>(f: F, name: Option<String>) -> Selfwhere
F: Fn(T, U) -> R + 'static,
pub fn new_with_optional_name<F>(f: F, name: Option<String>) -> Selfwhere
F: Fn(T, U) -> R + 'static,
Creates a new named bi-transformer with an optional name.
Wraps the provided closure and assigns it an optional name.
Sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
Gets the name of this bi-transformer.
§Returns
Returns Some(&str) if a name was set, None otherwise.
pub fn when<P>(&self, predicate: P) -> RcConditionalBiTransformer<T, U, R>where
P: BiPredicate<T, U> + 'static,
pub fn and_then<S, F>(&self, after: F) -> RcBiTransformer<T, U, S>where
S: 'static,
F: Transformer<R, S> + 'static,
Source§impl<T, U, R> RcBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: Clone + 'static,
impl<T, U, R> RcBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: Clone + 'static,
Sourcepub fn constant(value: R) -> RcBiTransformer<T, U, R>
pub fn constant(value: R) -> RcBiTransformer<T, U, R>
Creates a constant bi-transformer
§Examples
/// rust /// use prism3_function::{RcBiTransformer, BiTransformer}; /// /// let constant = RcBiTransformer::constant("hello"); /// assert_eq!(constant.apply(123, 456), "hello"); ///
Trait Implementations§
Source§impl<T, U, R> BiTransformer<T, U, R> for RcBiTransformer<T, U, R>
impl<T, U, R> BiTransformer<T, U, R> for RcBiTransformer<T, U, R>
Source§fn apply(&self, first: T, second: U) -> R
fn apply(&self, first: T, second: U) -> R
Source§fn into_box(self) -> BoxBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
fn into_box(self) -> BoxBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
Source§fn into_rc(self) -> RcBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
fn into_rc(self) -> RcBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
Source§fn to_box(&self) -> BoxBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
fn to_box(&self) -> BoxBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
Source§fn to_rc(&self) -> RcBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
fn to_rc(&self) -> RcBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
Source§fn to_fn(&self) -> impl Fn(T, U) -> R
fn to_fn(&self) -> impl Fn(T, U) -> R
&self. Read more