pub struct FnCollate<F> { /* private fields */ }Expand description
Adapts an ordinary fallible closure to Collate.
§Examples
use std::convert::Infallible;
use rusttorch_data::{Collate, FnCollate};
let mut collator = FnCollate::new(|samples: Vec<Vec<i64>>| {
Ok::<_, Infallible>(samples.into_iter().flatten().collect::<Vec<_>>())
});
assert_eq!(collator.collate(vec![vec![1, 2], vec![3]])?, [1, 2, 3]);Implementations§
Trait Implementations§
impl<F: Copy> Copy for FnCollate<F>
Auto Trait Implementations§
impl<F> Freeze for FnCollate<F>where
F: Freeze,
impl<F> RefUnwindSafe for FnCollate<F>where
F: RefUnwindSafe,
impl<F> Send for FnCollate<F>where
F: Send,
impl<F> Sync for FnCollate<F>where
F: Sync,
impl<F> Unpin for FnCollate<F>where
F: Unpin,
impl<F> UnsafeUnpin for FnCollate<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for FnCollate<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