Replace `.nth(0)` with `.next()`

Clippy[1] says that `.next()` is more readable than `.nth(0)`.

[1]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_nth_zero
This commit is contained in:
Cole Helbling 2020-01-16 16:59:27 -08:00 committed by Kirill Chibisov
parent 3203d2b3fa
commit 091296828a
3 changed files with 4 additions and 5 deletions

View File

@ -338,8 +338,7 @@ impl Descriptor {
let fallbacks = if load_fallbacks { let fallbacks = if load_fallbacks {
descriptors_for_family("Menlo") descriptors_for_family("Menlo")
.into_iter() .into_iter()
.filter(|d| d.font_name == "Menlo-Regular") .find(|d| d.font_name == "Menlo-Regular")
.nth(0)
.map(|descriptor| { .map(|descriptor| {
let menlo = ct_new_from_descriptor(&descriptor.ct_descriptor, size); let menlo = ct_new_from_descriptor(&descriptor.ct_descriptor, size);

View File

@ -518,7 +518,7 @@ impl PatternRef {
} }
pub fn get_width(&self) -> Option<Width> { pub fn get_width(&self) -> Option<Width> {
unsafe { self.get_integer(b"width\0").nth(0).map(Width::from) } unsafe { self.get_integer(b"width\0").next().map(Width::from) }
} }
pub fn rgba(&self) -> RgbaPropertyIter { pub fn rgba(&self) -> RgbaPropertyIter {

View File

@ -251,7 +251,7 @@ impl FreeTypeRasterizer {
} }
fn face_from_pattern(&mut self, pattern: &fc::Pattern) -> Result<Option<FontKey>, Error> { fn face_from_pattern(&mut self, pattern: &fc::Pattern) -> Result<Option<FontKey>, Error> {
if let (Some(path), Some(index)) = (pattern.file(0), pattern.index().nth(0)) { if let (Some(path), Some(index)) = (pattern.file(0), pattern.index().next()) {
if let Some(key) = self.keys.get(&path) { if let Some(key) = self.keys.get(&path) {
return Ok(Some(*key)); return Ok(Some(*key));
} }
@ -547,7 +547,7 @@ impl FreeTypeRasterizer {
let config = fc::Config::get_current(); let config = fc::Config::get_current();
match fc::font_match(config, &mut pattern) { match fc::font_match(config, &mut pattern) {
Some(pattern) => { Some(pattern) => {
if let (Some(path), Some(_)) = (pattern.file(0), pattern.index().nth(0)) { if let (Some(path), Some(_)) = (pattern.file(0), pattern.index().next()) {
match self.keys.get(&path) { match self.keys.get(&path) {
// We've previously loaded this font, so don't // We've previously loaded this font, so don't
// load it again. // load it again.