From edbe00c62b610d4b84c811a8efce105c3d01422e Mon Sep 17 00:00:00 2001 From: awiouy Date: Tue, 13 Feb 2018 08:33:50 +0100 Subject: [PATCH] core API: move StrChunks* to metadata --- core/src/util/mod.rs | 26 -------------------------- metadata/src/lib.rs | 27 ++++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/core/src/util/mod.rs b/core/src/util/mod.rs index 32b058ad..9c373eaa 100644 --- a/core/src/util/mod.rs +++ b/core/src/util/mod.rs @@ -29,32 +29,6 @@ pub fn powm(base: &BigUint, exp: &BigUint, modulus: &BigUint) -> BigUint { result } -pub struct StrChunks<'s>(&'s str, usize); - -pub trait StrChunksExt { - fn chunks(&self, size: usize) -> StrChunks; -} - -impl StrChunksExt for str { - fn chunks(&self, size: usize) -> StrChunks { - StrChunks(self, size) - } -} - -impl<'s> Iterator for StrChunks<'s> { - type Item = &'s str; - fn next(&mut self) -> Option<&'s str> { - let &mut StrChunks(data, size) = self; - if data.is_empty() { - None - } else { - let ret = Some(&data[..size]); - self.0 = &data[size..]; - ret - } - } -} - pub trait ReadSeek: ::std::io::Read + ::std::io::Seek {} impl ReadSeek for T {} diff --git a/metadata/src/lib.rs b/metadata/src/lib.rs index 664d9a22..0103a3b0 100644 --- a/metadata/src/lib.rs +++ b/metadata/src/lib.rs @@ -14,7 +14,6 @@ use linear_map::LinearMap; use core::mercury::MercuryError; use core::session::Session; use core::spotify_id::{FileId, SpotifyId}; -use core::util::StrChunksExt; pub use protocol::metadata::AudioFile_Format as FileFormat; @@ -215,3 +214,29 @@ impl Metadata for Artist { } } } + +struct StrChunks<'s>(&'s str, usize); + +trait StrChunksExt { + fn chunks(&self, size: usize) -> StrChunks; +} + +impl StrChunksExt for str { + fn chunks(&self, size: usize) -> StrChunks { + StrChunks(self, size) + } +} + +impl<'s> Iterator for StrChunks<'s> { + type Item = &'s str; + fn next(&mut self) -> Option<&'s str> { + let &mut StrChunks(data, size) = self; + if data.is_empty() { + None + } else { + let ret = Some(&data[..size]); + self.0 = &data[size..]; + ret + } + } +}