File tree 4 files changed +9
-7
lines changed
4 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 5
5
//! we need for the compiler.
6
6
//!
7
7
//! The implementation here is based on `std.json` from Inko's standard library.
8
+ use std:: fmt:: Display ;
8
9
use std:: string:: ToString ;
9
10
10
11
const DQUOTE : i64 = 0x22 ;
@@ -62,9 +63,9 @@ pub(crate) enum Json {
62
63
Bool ( bool ) ,
63
64
}
64
65
65
- impl ToString for Json {
66
- fn to_string ( & self ) -> String {
67
- Generator :: new ( ) . generate ( self )
66
+ impl Display for Json {
67
+ fn fmt ( & self , f : & mut std :: fmt :: Formatter < ' _ > ) -> std :: fmt :: Result {
68
+ Generator :: new ( ) . generate ( self ) . fmt ( f )
68
69
}
69
70
}
70
71
@@ -166,10 +167,8 @@ mod tests {
166
167
obj. add ( "array" , Json :: Array ( vec ! [ Json :: Int ( 10 ) , Json :: Int ( 20 ) ] ) ) ;
167
168
obj. add ( "bool" , Json :: Bool ( true ) ) ;
168
169
169
- let json = Generator :: new ( ) . generate ( & Json :: Object ( obj) ) ;
170
-
171
170
assert_eq ! (
172
- json ,
171
+ Json :: Object ( obj ) . to_string ( ) ,
173
172
"{
174
173
\" string\" : \" foo\\ nbar\" ,
175
174
\" int\" : 42,
Original file line number Diff line number Diff line change 1
1
#![ allow( clippy:: new_without_default) ]
2
2
#![ allow( clippy:: enum_variant_names) ]
3
+ #![ allow( clippy:: assigning_clones) ]
3
4
4
5
mod diagnostics;
5
6
pub mod docs;
Original file line number Diff line number Diff line change @@ -428,7 +428,7 @@ impl DecisionState {
428
428
action : RegisterAction ,
429
429
) {
430
430
self . actions . insert ( child, action) ;
431
- self . child_registers . entry ( parent) . or_insert_with ( Vec :: new ) . push ( child) ;
431
+ self . child_registers . entry ( parent) . or_default ( ) . push ( child) ;
432
432
}
433
433
}
434
434
Original file line number Diff line number Diff line change
1
+ #![ allow( clippy:: assigning_clones) ]
2
+
1
3
mod command;
2
4
mod error;
3
5
mod http;
You can’t perform that action at this time.
0 commit comments