remove unwrap
s in Value::to_css_string
This commit is contained in:
parent
5d5e7adb98
commit
d90ef7fa41
@ -82,11 +82,11 @@ fn visit_quoted_string(buf: &mut String, force_double_quote: bool, string: &str)
|
|||||||
buffer.push(hex_char_for(c as u32 >> 4))
|
buffer.push(hex_char_for(c as u32 >> 4))
|
||||||
}
|
}
|
||||||
buffer.push(hex_char_for(c as u32 & 0xF));
|
buffer.push(hex_char_for(c as u32 & 0xF));
|
||||||
if iter.peek().is_none() {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
let next = iter.peek().unwrap();
|
let next = match iter.peek() {
|
||||||
|
Some(v) => v,
|
||||||
|
None => break,
|
||||||
|
};
|
||||||
|
|
||||||
if next.is_ascii_hexdigit() || next == &' ' || next == &'\t' {
|
if next.is_ascii_hexdigit() || next == &' ' || next == &'\t' {
|
||||||
buffer.push(' ');
|
buffer.push(' ');
|
||||||
@ -148,7 +148,7 @@ impl Value {
|
|||||||
Self::List(vals, sep, brackets) => match brackets {
|
Self::List(vals, sep, brackets) => match brackets {
|
||||||
Brackets::None => Cow::owned(
|
Brackets::None => Cow::owned(
|
||||||
vals.iter()
|
vals.iter()
|
||||||
.filter(|x| !x.is_null(span).unwrap())
|
.filter(|x| !x.clone().is_null(span).unwrap_or(false))
|
||||||
.map(|x| x.to_css_string(span))
|
.map(|x| x.to_css_string(span))
|
||||||
.collect::<SassResult<Vec<Cow<'static, str>>>>()?
|
.collect::<SassResult<Vec<Cow<'static, str>>>>()?
|
||||||
.join(sep.as_str()),
|
.join(sep.as_str()),
|
||||||
@ -156,7 +156,7 @@ impl Value {
|
|||||||
Brackets::Bracketed => Cow::owned(format!(
|
Brackets::Bracketed => Cow::owned(format!(
|
||||||
"[{}]",
|
"[{}]",
|
||||||
vals.iter()
|
vals.iter()
|
||||||
.filter(|x| !x.is_null(span).unwrap())
|
.filter(|x| !x.is_null(span).unwrap_or(false))
|
||||||
.map(|x| x.to_css_string(span))
|
.map(|x| x.to_css_string(span))
|
||||||
.collect::<SassResult<Vec<Cow<'static, str>>>>()?
|
.collect::<SassResult<Vec<Cow<'static, str>>>>()?
|
||||||
.join(sep.as_str()),
|
.join(sep.as_str()),
|
||||||
@ -199,7 +199,7 @@ impl Value {
|
|||||||
Self::Null => Cow::const_str(""),
|
Self::Null => Cow::const_str(""),
|
||||||
Self::ArgList(args) => Cow::owned(
|
Self::ArgList(args) => Cow::owned(
|
||||||
args.iter()
|
args.iter()
|
||||||
.filter(|x| !x.is_null(span).unwrap())
|
.filter(|x| !x.is_null(span).unwrap_or(false))
|
||||||
.map(|a| Ok(a.node.to_css_string(span)?))
|
.map(|a| Ok(a.node.to_css_string(span)?))
|
||||||
.collect::<SassResult<Vec<Cow<'static, str>>>>()?
|
.collect::<SassResult<Vec<Cow<'static, str>>>>()?
|
||||||
.join(", "),
|
.join(", "),
|
||||||
|
@ -314,3 +314,19 @@ test!(
|
|||||||
"a {\n color: 3;\n}\n"
|
"a {\n color: 3;\n}\n"
|
||||||
);
|
);
|
||||||
test!(empty_bracketed_list, "a {\n empty: [];\n}\n");
|
test!(empty_bracketed_list, "a {\n empty: [];\n}\n");
|
||||||
|
error!(
|
||||||
|
invalid_item_in_space_separated_list,
|
||||||
|
"a {\n color: red color * #abc;\n}\n", "Error: Undefined operation \"color * #abc\"."
|
||||||
|
);
|
||||||
|
error!(
|
||||||
|
invalid_item_in_comma_separated_list,
|
||||||
|
"a {\n color: red, color * #abc;\n}\n", "Error: Undefined operation \"color * #abc\"."
|
||||||
|
);
|
||||||
|
error!(
|
||||||
|
invalid_item_in_space_separated_list_inside_interpolation,
|
||||||
|
"a {\n color: #{red color * #abc};\n}\n", "Error: Undefined operation \"color * #abc\"."
|
||||||
|
);
|
||||||
|
error!(
|
||||||
|
invalid_item_in_comma_separated_list_inside_interpolation,
|
||||||
|
"a {\n color: #{red, color * #abc};\n}\n", "Error: Undefined operation \"color * #abc\"."
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user