pub struct ArcBiTransformer<T, U, R> { /* private fields */ }Expand description
ArcBiTransformer - thread-safe bi-transformer wrapper
A thread-safe, clonable bi-transformer wrapper suitable for multi-threaded scenarios. Can be called multiple times and shared across threads.
§Features
- Based on:
Arc<dyn Fn(T, U) -> R + Send + Sync> - Ownership: Shared ownership via reference counting
- Reusability: Can be called multiple times (each call consumes its inputs)
- Thread Safety: Thread-safe (
Send + Syncrequired) - Clonable: Cheap cloning via
Arc::clone
§Author
Haixing Hu
Implementations§
Source§impl<T, U, R> ArcBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
impl<T, U, R> ArcBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
Sourcepub fn new<F>(f: F) -> Self
pub fn new<F>(f: F) -> Self
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) -> Self
pub fn new_with_name<F>(name: &str, f: F) -> Self
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>) -> Self
pub fn new_with_optional_name<F>(f: F, name: Option<String>) -> Self
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) -> ArcConditionalBiTransformer<T, U, R>
pub fn and_then<S, F>(&self, after: F) -> ArcBiTransformer<T, U, S>
Source§impl<T, U, R> ArcBiTransformer<T, U, R>
impl<T, U, R> ArcBiTransformer<T, U, R>
Sourcepub fn constant(value: R) -> ArcBiTransformer<T, U, R>
pub fn constant(value: R) -> ArcBiTransformer<T, U, R>
Creates a constant bi-transformer
§Examples
/// rust /// use prism3_function::{ArcBiTransformer, BiTransformer}; /// /// let constant = ArcBiTransformer::constant("hello"); /// assert_eq!(constant.apply(123, 456), "hello"); ///
Trait Implementations§
Source§impl<T, U, R> BiTransformer<T, U, R> for ArcBiTransformer<T, U, R>
impl<T, U, R> BiTransformer<T, U, R> for ArcBiTransformer<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 into_arc(self) -> ArcBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
fn into_arc(self) -> ArcBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
Source§fn into_once(self) -> BoxBiTransformerOnce<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
fn into_once(self) -> BoxBiTransformerOnce<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_arc(&self) -> ArcBiTransformer<T, U, R>where
T: 'static,
U: 'static,
R: 'static,
fn to_arc(&self) -> ArcBiTransformer<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