From ba3d43f7b2a18984be27f3d472884a19f3adce4c Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 27 Dec 2020 20:45:20 +0100 Subject: Refresh function call and dictionary syntax - No colon between function name and arguments, just whitespace - "Named" arguments (previously "keyword" arguments) use colon instead of equals sign --- src/eval/args.rs | 2 +- src/eval/dict.rs | 16 +++++++--------- src/eval/value.rs | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src/eval') diff --git a/src/eval/args.rs b/src/eval/args.rs index 765ae09c..b379b975 100644 --- a/src/eval/args.rs +++ b/src/eval/args.rs @@ -86,7 +86,7 @@ impl Args { }) } - /// Retrieve and remove all matching keyword arguments. + /// Retrieve and remove all matching named arguments. pub fn find_all_str(&mut self) -> impl Iterator + '_ where T: TryFromValue, diff --git a/src/eval/dict.rs b/src/eval/dict.rs index 1374c840..efa5cb37 100644 --- a/src/eval/dict.rs +++ b/src/eval/dict.rs @@ -160,11 +160,9 @@ impl Debug for Dict { if self.0 { f.write_str("\"")?; } - if f.alternate() { - f.write_str(" = ")?; - } else { - f.write_str("=")?; - } + + f.write_str(": ")?; + self.2.fmt(f) } } @@ -511,13 +509,13 @@ mod tests { dict.insert("sp ace", "quotes"); assert_eq!( format!("{:?}", dict), - r#"(10="hello", "sp ace"="quotes", twenty="there")"#, + r#"(10: "hello", "sp ace": "quotes", twenty: "there")"#, ); assert_eq!(format!("{:#?}", dict).lines().collect::>(), [ "(", - r#" 10 = "hello","#, - r#" "sp ace" = "quotes","#, - r#" twenty = "there","#, + r#" 10: "hello","#, + r#" "sp ace": "quotes","#, + r#" twenty: "there","#, ")", ]); } diff --git a/src/eval/value.rs b/src/eval/value.rs index a27e9aa9..f15ae0c5 100644 --- a/src/eval/value.rs +++ b/src/eval/value.rs @@ -36,7 +36,7 @@ pub enum Value { Color(Color), /// A string: `"string"`. Str(String), - /// A dictionary value: `(false, 12cm, greeting="hi")`. + /// A dictionary value: `(false, 12cm, greeting: "hi")`. Dict(ValueDict), /// A content value: `{*Hi* there}`. Content(SynTree), @@ -125,7 +125,7 @@ impl Debug for Value { /// /// # Example /// ```typst -/// (false, 12cm, greeting="hi") +/// (false, 12cm, greeting: "hi") /// ``` pub type ValueDict = Dict>; -- cgit v1.2.3