11///|
2- typealias @cirru_parser . Cirru
2+ using @cirru_parser { type Cirru }
33
44///|
55pub (all ) suberror EdnCommonError String derive (Eq , Hash , Default , Show )
66
77///|
8- pub impl @strconv .FromStr for Edn with from_string (s ) {
9- Edn ::parse (s )
8+ pub impl @strconv .FromStr for Edn with from_str (s ) {
9+ Edn ::parse (s . to_string () )
1010}
1111
1212///|
@@ -39,11 +39,12 @@ fn extract_cirru_edn(
3939 "" => raise @strconv .StrConvError ("empty string is invalid for edn" )
4040 s1 =>
4141 match s1 .get_char (0 ).unwrap () {
42- '\' ' => Symbol (s1 . substring ( start = 1 ))
43- ':' => Tag (s1 . substring ( start = 1 ))
44- '"' | '|' => Str (s1 . substring ( start = 1 ))
42+ '\' ' => Symbol (try ! s1 [ 1 :]. to_string ( ))
43+ ':' => Tag (try ! s1 [ 1 :]. to_string ( ))
44+ '"' | '|' => Str (try ! s1 [ 1 :]. to_string ( ))
4545 _ =>
46- match (try ? @strconv .parse_double (s1 .trim (" " ).to_string ())) {
46+ match
47+ (try ? @strconv .parse_double (s1 .trim (char_set = " " ).to_string ())) {
4748 Ok (f ) => Number (f )
4849 Err (e ) =>
4950 match e {
@@ -176,7 +177,8 @@ fn extract_cirru_edn(
176177 "%{}" =>
177178 if xs .length () >= 3 {
178179 let name = match xs [1 ] {
179- Leaf (s ) => EdnTag ::new (s .trim_start (":" ).to_string ())
180+ Leaf (s ) =>
181+ EdnTag ::new (s .trim_start (char_set = ":" ).to_string ())
180182 List (e ) =>
181183 raise @strconv .StrConvError (
182184 "expected record name in string: " + e .to_string (),
@@ -197,7 +199,12 @@ fn extract_cirru_edn(
197199 match (ys [0 ], try ? extract_cirru_edn (ys [1 ])) {
198200 (Leaf (s ), Ok (v )) =>
199201 entries .push (
200- (EdnTag ::new (s .trim_start (":" ).to_string ()), v ),
202+ (
203+ EdnTag ::new (
204+ s .trim_start (char_set = ":" ).to_string (),
205+ ),
206+ v ,
207+ ),
201208 )
202209 (Leaf (s ), Err (e )) =>
203210 raise @strconv .StrConvError (
@@ -378,14 +385,11 @@ fn assemble_cirru_node(data : Edn) -> @cirru_parser.Cirru raise EdnCommonError {
378385/// generate Cirru code from Edn
379386pub fn Edn ::format (
380387 data : Self ,
381- use_inline ? : Bool ,
388+ use_inline ? : Bool = false ,
382389) -> String raise EdnCommonError {
383- let options : @cirru_parser .CirruWriterOptions = {
384- use_inline : use_inline .unwrap_or (false ),
385- }
386390 let ret = match assemble_cirru_node (data ) {
387- Leaf (s ) => try ? Cirru ::format ([List ([Leaf ("do" ), Leaf (s )])], options )
388- List (xs ) => try ? Cirru ::format ([List (xs )], options )
391+ Leaf (s ) => try ? Cirru ::format ([List ([Leaf ("do" ), Leaf (s )])], use_inline ~ )
392+ List (xs ) => try ? Cirru ::format ([List (xs )], use_inline ~ )
389393 }
390394 match ret {
391395 Ok (s ) => s
0 commit comments