pub struct RiFactory<T> { /* private fields */ }Expand description
This is the factory implementation of GetBeginEndOption for std::ops::RangeInclusive.
Implementations§
Source§impl<T> RiFactory<T>
impl<T> RiFactory<T>
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/beyond_any.rs (line 63)
55fn main() {
56 let t = CustomIncDecCpCmp {};
57
58 let mut isec = Intersector::new(
59 Vec::new(), // Container for our internal ranges
60 Point { p: 1 }, // step
61 Point { p: 1 }, // Rebound value
62 t, // our compare instance
63 RiFactory::new(), // Factory used to construct new ranges
64 );
65
66 // Note: an internal RangeInclusive instance is
67 // generated for every range that is successfully added.
68 // This means it is safe to drop the orginal range values
69 // after they are loaded into the Intersector instance.
70 isec.add_range(&(..Point { p: 2 }));
71 isec.add_range(&(Point { p: 1 }..Point { p: 3 }));
72 isec.add_range(&(Point { p: 3 }..=Point { p: 4 }));
73 isec.add_range(&(Point { p: 3 }..));
74 for r in isec.into_iter() {
75 println!("X: {:?}, Y: {:?}", r.start(), r.end());
76 }
77 // Output will be:
78 // X: Point { p: 0 }, Y: Point { p: 0 }
79 // X: Point { p: 1 }, Y: Point { p: 1 }
80 // X: Point { p: 2 }, Y: Point { p: 2 }
81 // X: Point { p: 3 }, Y: Point { p: 4 }
82 // X: Point { p: 5 }, Y: Point { p: 8 }
83}Trait Implementations§
impl<T: Copy> Copy for RiFactory<T>
Source§impl<T> GetBeginEndOption<T, RangeInclusive<T>> for RiFactory<T>
impl<T> GetBeginEndOption<T, RangeInclusive<T>> for RiFactory<T>
Auto Trait Implementations§
impl<T> Freeze for RiFactory<T>
impl<T> RefUnwindSafe for RiFactory<T>where
T: RefUnwindSafe,
impl<T> Send for RiFactory<T>where
T: Send,
impl<T> Sync for RiFactory<T>where
T: Sync,
impl<T> Unpin for RiFactory<T>where
T: Unpin,
impl<T> UnsafeUnpin for RiFactory<T>
impl<T> UnwindSafe for RiFactory<T>where
T: 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