Skip to content

Commit

Permalink
Replacing chain(core::iter::once(x)) by chain([x]) (#3419)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed May 9, 2023
1 parent 458e536 commit 8e389a5
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
6 changes: 2 additions & 4 deletions provider/datagen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@ pub fn key<S: AsRef<str>>(string: S) -> Option<DataKey> {
lazy_static::lazy_static! {
static ref LOOKUP: std::collections::HashMap<&'static str, DataKey> = all_keys_with_experimental()
.into_iter()
.chain(std::iter::once(
icu_provider::hello_world::HelloWorldV1Marker::KEY,
))
.chain([icu_provider::hello_world::HelloWorldV1Marker::KEY])
.map(|k| (k.path().get(), k))
.collect();
}
Expand Down Expand Up @@ -452,7 +450,7 @@ pub fn datagen(
LocaleInclude::Explicit(
ls.iter()
.cloned()
.chain(core::iter::once(icu_locid::LanguageIdentifier::UND))
.chain([icu_locid::LanguageIdentifier::UND])
.collect(),
)
})
Expand Down
2 changes: 1 addition & 1 deletion provider/datagen/src/transform/cldr/decimal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl crate::DatagenProvider {
);
data_locale
})
.chain(core::iter::once(last))
.chain([last])
})
.collect(),
))
Expand Down
4 changes: 1 addition & 3 deletions tools/testdata-scripts/src/bin/make-testdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ fn main() {
Some(LOCALES),
&icu_datagen::all_keys_with_experimental()
.into_iter()
.chain(core::iter::once(
icu_provider::hello_world::HelloWorldV1Marker::KEY,
))
.chain([icu_provider::hello_world::HelloWorldV1Marker::KEY])
.collect::<Vec<_>>(),
&source,
vec![json_out, blob_out, mod_out, postcard_out],
Expand Down
3 changes: 1 addition & 2 deletions utils/zerovec/src/flexzerovec/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ impl FlexZeroSlice {
/// assert_eq!(pairs_it.next(), None);
/// ```
pub fn iter_pairs(&self) -> impl Iterator<Item = (usize, Option<usize>)> + '_ {
self.iter()
.zip(self.iter().skip(1).map(Some).chain(core::iter::once(None)))
self.iter().zip(self.iter().skip(1).map(Some).chain([None]))
}

/// Creates a `Vec<usize>` from a [`FlexZeroSlice`] (or `FlexZeroVec`).
Expand Down
2 changes: 1 addition & 1 deletion utils/zerovec/src/varzerovec/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ impl<'a, T: VarULE + ?Sized, F: VarZeroVecFormat> VarZeroVecComponents<'a, T, F>
.copied()
.map(F::rawbytes_to_usize)
.skip(1)
.chain(core::iter::once(self.things.len())),
.chain([self.things.len()]),
)
.map(move |(start, end)| unsafe { self.things.get_unchecked(start..end) })
.map(|bytes| unsafe { T::from_byte_slice_unchecked(bytes) })
Expand Down

0 comments on commit 8e389a5

Please sign in to comment.