replace .get(0)
with .first()
This commit is contained in:
parent
df1456f9b1
commit
61ef52eb3f
@ -33,7 +33,7 @@ fn simple_selectors(mut args: CallArgs, parser: &mut Parser<'_>) -> SassResult<V
|
|||||||
}
|
}
|
||||||
|
|
||||||
let compound = if let Some(ComplexSelectorComponent::Compound(compound)) =
|
let compound = if let Some(ComplexSelectorComponent::Compound(compound)) =
|
||||||
selector.0.components[0].components.get(0).cloned()
|
selector.0.components[0].components.first().cloned()
|
||||||
{
|
{
|
||||||
compound
|
compound
|
||||||
} else {
|
} else {
|
||||||
|
@ -129,8 +129,8 @@ impl Css {
|
|||||||
for rule in body {
|
for rule in body {
|
||||||
match rule {
|
match rule {
|
||||||
Stmt::RuleSet { .. } => vals.extend(self.parse_stmt(rule)?),
|
Stmt::RuleSet { .. } => vals.extend(self.parse_stmt(rule)?),
|
||||||
Stmt::Style(s) => vals.get_mut(0).unwrap().push_style(s),
|
Stmt::Style(s) => vals.first_mut().unwrap().push_style(s),
|
||||||
Stmt::Comment(s) => vals.get_mut(0).unwrap().push_comment(s),
|
Stmt::Comment(s) => vals.first_mut().unwrap().push_comment(s),
|
||||||
Stmt::Media(m) => {
|
Stmt::Media(m) => {
|
||||||
let MediaRule { query, body, .. } = *m;
|
let MediaRule { query, body, .. } = *m;
|
||||||
vals.push(Toplevel::Media { query, body })
|
vals.push(Toplevel::Media { query, body })
|
||||||
@ -167,7 +167,7 @@ impl Css {
|
|||||||
k @ Stmt::KeyframesRuleSet(..) => {
|
k @ Stmt::KeyframesRuleSet(..) => {
|
||||||
unreachable!("@keyframes ruleset {:?}", k)
|
unreachable!("@keyframes ruleset {:?}", k)
|
||||||
}
|
}
|
||||||
Stmt::Import(s) => vals.get_mut(0).unwrap().push_import(s),
|
Stmt::Import(s) => vals.first_mut().unwrap().push_import(s),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
vals
|
vals
|
||||||
@ -204,7 +204,7 @@ impl Css {
|
|||||||
let mut vals = vec![Toplevel::new_keyframes_rule(selector)];
|
let mut vals = vec![Toplevel::new_keyframes_rule(selector)];
|
||||||
for rule in body {
|
for rule in body {
|
||||||
match rule {
|
match rule {
|
||||||
Stmt::Style(s) => vals.get_mut(0).unwrap().push_style(s),
|
Stmt::Style(s) => vals.first_mut().unwrap().push_style(s),
|
||||||
Stmt::KeyframesRuleSet(..) => vals.extend(self.parse_stmt(rule)?),
|
Stmt::KeyframesRuleSet(..) => vals.extend(self.parse_stmt(rule)?),
|
||||||
_ => todo!(),
|
_ => todo!(),
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ impl Css {
|
|||||||
// this is how we print newlines between unrelated styles
|
// this is how we print newlines between unrelated styles
|
||||||
// it could probably be refactored
|
// it could probably be refactored
|
||||||
if !v.is_empty() {
|
if !v.is_empty() {
|
||||||
if let Some(Toplevel::MultilineComment(..)) = v.get(0) {
|
if let Some(Toplevel::MultilineComment(..)) = v.first() {
|
||||||
} else if is_first {
|
} else if is_first {
|
||||||
is_first = false;
|
is_first = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -105,7 +105,7 @@ impl<'a> Parser<'a> {
|
|||||||
comma_separated.push(space_separated.pop().unwrap());
|
comma_separated.push(space_separated.pop().unwrap());
|
||||||
} else {
|
} else {
|
||||||
let mut span = space_separated
|
let mut span = space_separated
|
||||||
.get(0)
|
.first()
|
||||||
.ok_or(("Expected expression.", val.span))?
|
.ok_or(("Expected expression.", val.span))?
|
||||||
.span;
|
.span;
|
||||||
comma_separated.push(
|
comma_separated.push(
|
||||||
|
@ -561,7 +561,7 @@ fn is_simple_selector_start(c: char) -> bool {
|
|||||||
/// with pseudo-class syntax (`:before`, `:after`, `:first-line`, or
|
/// with pseudo-class syntax (`:before`, `:after`, `:first-line`, or
|
||||||
/// `:first-letter`)
|
/// `:first-letter`)
|
||||||
fn is_fake_pseudo_element(name: &str) -> bool {
|
fn is_fake_pseudo_element(name: &str) -> bool {
|
||||||
match name.as_bytes().get(0) {
|
match name.as_bytes().first() {
|
||||||
Some(b'a') | Some(b'A') => name.to_ascii_lowercase() == "after",
|
Some(b'a') | Some(b'A') => name.to_ascii_lowercase() == "after",
|
||||||
Some(b'b') | Some(b'B') => name.to_ascii_lowercase() == "before",
|
Some(b'b') | Some(b'B') => name.to_ascii_lowercase() == "before",
|
||||||
Some(b'f') | Some(b'F') => match name.to_ascii_lowercase().as_str() {
|
Some(b'f') | Some(b'F') => match name.to_ascii_lowercase().as_str() {
|
||||||
|
@ -364,7 +364,7 @@ impl SimpleSelector {
|
|||||||
};
|
};
|
||||||
complex
|
complex
|
||||||
.components
|
.components
|
||||||
.get(0)
|
.first()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_compound()
|
.as_compound()
|
||||||
.components
|
.components
|
||||||
|
Loading…
x
Reference in New Issue
Block a user