pub struct FnTransform<F> { /* private fields */ }Expand description
Adapts a fallible closure into a Transform.
use std::convert::Infallible;
use rusttorch_data::{FnTransform, TaskContext, Transform};
let context = TaskContext {
loader_seed: 42,
epoch: 3,
rank: 1,
logical_sample: 99,
stage: 7,
cancellation: rusttorch_data::CancellationToken::new(),
deadline: rusttorch_data::Deadline::none(),
};
let mut double = FnTransform::new(|value: i64, _: &TaskContext| {
Ok::<_, Infallible>(value * 2)
});
assert_eq!(double.transform(3, &context), Ok(6));
assert_eq!(context.deterministic_seed(), 0x1d7d_73dc_f6e9_4f2d);Implementations§
Source§impl<F> FnTransform<F>
impl<F> FnTransform<F>
Trait Implementations§
Source§impl<F: Clone> Clone for FnTransform<F>
impl<F: Clone> Clone for FnTransform<F>
Source§fn clone(&self) -> FnTransform<F>
fn clone(&self) -> FnTransform<F>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<F: Copy> Copy for FnTransform<F>
Source§impl<F: Debug> Debug for FnTransform<F>
impl<F: Debug> Debug for FnTransform<F>
Source§impl<Input, Output, E, F> Transform<Input> for FnTransform<F>
impl<Input, Output, E, F> Transform<Input> for FnTransform<F>
Auto Trait Implementations§
impl<F> Freeze for FnTransform<F>where
F: Freeze,
impl<F> RefUnwindSafe for FnTransform<F>where
F: RefUnwindSafe,
impl<F> Send for FnTransform<F>where
F: Send,
impl<F> Sync for FnTransform<F>where
F: Sync,
impl<F> Unpin for FnTransform<F>where
F: Unpin,
impl<F> UnsafeUnpin for FnTransform<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for FnTransform<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more