uriplaylistbin: factor out create_items()

This commit is contained in:
Guillaume Desmottes 2021-12-22 12:49:30 +01:00
parent 7c909e59a9
commit 4a5815cc97

View file

@ -617,6 +617,15 @@ struct Playlist {
impl Playlist {
fn new(uris: Vec<String>, iterations: u32) -> Self {
Self {
items: Self::create_items(uris, iterations),
}
}
fn create_items(
uris: Vec<String>,
iterations: u32,
) -> Box<dyn Iterator<Item = Item> + Send + Sync> {
fn infinite_iter(uris: Vec<String>) -> Box<dyn Iterator<Item = Item> + Send + Sync> {
Box::new(
uris.into_iter()
@ -642,13 +651,11 @@ impl Playlist {
)
}
let items = if iterations == 0 {
if iterations == 0 {
infinite_iter(uris)
} else {
finite_iter(uris, iterations)
};
Self { items }
}
}
fn next(&mut self) -> Result<Option<Item>, PlaylistError> {