Skip to main content

IntoSource

Trait IntoSource 

Source
pub trait IntoSource: IntoIterator + Sized {
    // Provided method
    fn into_source(self) -> Source<Self::Item, NotUsed>
       where Self::Item: Clone + Send + Sync + 'static { ... }
}
Expand description

Converts any IntoIterator into a Source explicitly.

Vec<T> and [T; N] also implement From for Source<T>, while broader iterables such as ranges intentionally use this trait to avoid a blanket From<I: IntoIterator> inference trap.

use datum::{IntoSource, Source};

let via_vec_into: Source<u64> = vec![1, 2, 3].into();
let via_array_into: Source<u64> = [1, 2, 3].into();
let via_range = (0_u64..3).into_source();
let via_from_iter = Source::from_iter(0_u64..3);
let via_from_iterator: Source<u64> = (0_u64..3).collect();

let _ = (
    via_vec_into,
    via_array_into,
    via_range,
    via_from_iter,
    via_from_iterator,
);
use datum::Source;

let _source: Source<u64> = (0_u64..3).into();

Provided Methods§

Source

fn into_source(self) -> Source<Self::Item, NotUsed>
where Self::Item: Clone + Send + Sync + 'static,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<I> IntoSource for I
where I: IntoIterator,