@@ -24,7 +24,7 @@ fn test_parse_null() {
24
24
assert_eq ! ( value. as_null( ) , Some ( ( ) ) ) ;
25
25
26
26
let mut buf: Vec < u8 > = Vec :: new ( ) ;
27
- value. to_writer ( & mut buf) . unwrap ( ) ;
27
+ value. to_vec ( & mut buf) . unwrap ( ) ;
28
28
assert_eq ! ( buf, b"\x20 \0 \0 \0 \0 \0 \0 \0 " ) ;
29
29
}
30
30
@@ -35,7 +35,7 @@ fn test_parse_boolean() {
35
35
assert_eq ! ( value. as_bool( ) , Some ( true ) ) ;
36
36
37
37
let mut buf: Vec < u8 > = Vec :: new ( ) ;
38
- value. to_writer ( & mut buf) . unwrap ( ) ;
38
+ value. to_vec ( & mut buf) . unwrap ( ) ;
39
39
assert_eq ! ( buf, b"\x20 \0 \0 \0 \x40 \0 \0 \0 " ) ;
40
40
41
41
let s = r#"false"# ;
@@ -44,7 +44,7 @@ fn test_parse_boolean() {
44
44
assert_eq ! ( value. as_bool( ) , Some ( false ) ) ;
45
45
46
46
let mut buf: Vec < u8 > = Vec :: new ( ) ;
47
- value. to_writer ( & mut buf) . unwrap ( ) ;
47
+ value. to_vec ( & mut buf) . unwrap ( ) ;
48
48
assert_eq ! ( buf, b"\x20 \0 \0 \0 \x30 \0 \0 \0 " ) ;
49
49
}
50
50
@@ -56,7 +56,7 @@ fn test_parse_number_int64() {
56
56
assert_eq ! ( value. as_i64( ) , Some ( -1234 ) ) ;
57
57
58
58
let mut buf: Vec < u8 > = Vec :: new ( ) ;
59
- value. to_writer ( & mut buf) . unwrap ( ) ;
59
+ value. to_vec ( & mut buf) . unwrap ( ) ;
60
60
assert_eq ! ( buf, b"\x20 \0 \0 \0 \x20 \0 \0 \x04 \x03 \0 \xd2 \x04 " ) ;
61
61
62
62
let s = r#"34567890"# ;
@@ -65,7 +65,7 @@ fn test_parse_number_int64() {
65
65
assert_eq ! ( value. as_i64( ) , Some ( 34567890 ) ) ;
66
66
67
67
let mut buf: Vec < u8 > = Vec :: new ( ) ;
68
- value. to_writer ( & mut buf) . unwrap ( ) ;
68
+ value. to_vec ( & mut buf) . unwrap ( ) ;
69
69
assert_eq ! ( buf, b"\x20 \0 \0 \0 \x20 \0 \0 \x06 \x02 \0 \xd2 \x76 \x0f \x02 " ) ;
70
70
}
71
71
@@ -77,7 +77,7 @@ fn test_parse_number_float64() {
77
77
assert_eq ! ( value. as_f64( ) , Some ( 0.0123 ) ) ;
78
78
79
79
let mut buf: Vec < u8 > = Vec :: new ( ) ;
80
- value. to_writer ( & mut buf) . unwrap ( ) ;
80
+ value. to_vec ( & mut buf) . unwrap ( ) ;
81
81
assert_eq ! ( buf, b"\x20 \0 \0 \0 \x20 \0 \0 \x03 \x02 \x04 \x7b " ) ;
82
82
83
83
let s = r#"12.34e5"# ;
@@ -86,7 +86,7 @@ fn test_parse_number_float64() {
86
86
assert_eq ! ( value. as_f64( ) , Some ( 1234000.0 ) ) ;
87
87
88
88
let mut buf: Vec < u8 > = Vec :: new ( ) ;
89
- value. to_writer ( & mut buf) . unwrap ( ) ;
89
+ value. to_vec ( & mut buf) . unwrap ( ) ;
90
90
assert_eq ! ( buf, b"\x20 \0 \0 \0 \x20 \0 \0 \x04 \0 \x03 \xd2 \x04 " ) ;
91
91
}
92
92
@@ -98,7 +98,7 @@ fn test_parse_string() {
98
98
assert_eq ! ( value. as_str( ) , Some ( & Cow :: from( "asd" ) ) ) ;
99
99
100
100
let mut buf: Vec < u8 > = Vec :: new ( ) ;
101
- value. to_writer ( & mut buf) . unwrap ( ) ;
101
+ value. to_vec ( & mut buf) . unwrap ( ) ;
102
102
assert_eq ! ( buf, b"\x20 \0 \0 \0 \x10 \0 \0 \x03 \x61 \x73 \x64 " ) ;
103
103
104
104
let s = r#""\\\"abc\\\"""# ;
@@ -107,7 +107,7 @@ fn test_parse_string() {
107
107
assert_eq ! ( value. as_str( ) , Some ( & Cow :: from( "\\ \" abc\\ \" " ) ) ) ;
108
108
109
109
let mut buf: Vec < u8 > = Vec :: new ( ) ;
110
- value. to_writer ( & mut buf) . unwrap ( ) ;
110
+ value. to_vec ( & mut buf) . unwrap ( ) ;
111
111
assert_eq ! ( buf, b"\x20 \0 \0 \0 \x10 \0 \0 \x07 \x5c \x22 \x61 \x62 \x63 \x5c \x22 " ) ;
112
112
113
113
let s = r#""测试abc""# ;
@@ -116,7 +116,7 @@ fn test_parse_string() {
116
116
assert_eq ! ( value. as_str( ) , Some ( & Cow :: from( "测试abc" ) ) ) ;
117
117
118
118
let mut buf: Vec < u8 > = Vec :: new ( ) ;
119
- value. to_writer ( & mut buf) . unwrap ( ) ;
119
+ value. to_vec ( & mut buf) . unwrap ( ) ;
120
120
assert_eq ! (
121
121
buf,
122
122
b"\x20 \0 \0 \0 \x10 \0 \0 \x09 \xe6 \xb5 \x8b \xe8 \xaf \x95 \x61 \x62 \x63 "
@@ -128,7 +128,7 @@ fn test_parse_string() {
128
128
assert_eq ! ( value. as_str( ) , Some ( & Cow :: from( "€" ) ) ) ;
129
129
130
130
let mut buf: Vec < u8 > = Vec :: new ( ) ;
131
- value. to_writer ( & mut buf) . unwrap ( ) ;
131
+ value. to_vec ( & mut buf) . unwrap ( ) ;
132
132
assert_eq ! ( buf, b"\x20 \0 \0 \0 \x10 \0 \0 \x03 \xe2 \x82 \xac " ) ;
133
133
}
134
134
@@ -139,15 +139,15 @@ fn test_parse_array() {
139
139
assert ! ( value. is_array( ) ) ;
140
140
141
141
let mut buf: Vec < u8 > = Vec :: new ( ) ;
142
- value. to_writer ( & mut buf) . unwrap ( ) ;
142
+ value. to_vec ( & mut buf) . unwrap ( ) ;
143
143
assert_eq ! ( buf, b"\x80 \0 \0 \x06 \x40 \0 \0 \0 \x20 \0 \0 \x02 \x20 \0 \0 \x03 \x20 \0 \0 \x05 \x10 \0 \0 \x03 \x50 \0 \0 \x04 \x39 \x30 \x03 \0 \xc8 \x02 \x04 \xc2 \x12 \x0c \x61 \x73 \x64 \x80 \0 \0 \0 " ) ;
144
144
145
145
let s = r#"[1,2,3,["a","b","c"]]"# ;
146
146
let value = parse_value ( s. as_bytes ( ) ) . unwrap ( ) ;
147
147
assert ! ( value. is_array( ) ) ;
148
148
149
149
let mut buf: Vec < u8 > = Vec :: new ( ) ;
150
- value. to_writer ( & mut buf) . unwrap ( ) ;
150
+ value. to_vec ( & mut buf) . unwrap ( ) ;
151
151
assert_eq ! ( buf, b"\x80 \0 \0 \x04 \x20 \0 \0 \x01 \x20 \0 \0 \x01 \x20 \0 \0 \x01 \x50 \0 \0 \x13 \x01 \x02 \x03 \x80 \0 \0 \x03 \x10 \0 \0 \x01 \x10 \0 \0 \x01 \x10 \0 \0 \x01 \x61 \x62 \x63 " ) ;
152
152
}
153
153
@@ -158,15 +158,15 @@ fn test_parse_object() {
158
158
assert ! ( value. is_object( ) ) ;
159
159
160
160
let mut buf: Vec < u8 > = Vec :: new ( ) ;
161
- value. to_writer ( & mut buf) . unwrap ( ) ;
161
+ value. to_vec ( & mut buf) . unwrap ( ) ;
162
162
assert_eq ! ( buf, b"\x40 \0 \0 \x02 \x10 \0 \0 \x02 \x10 \0 \0 \x02 \x10 \0 \0 \x02 \x10 \0 \0 \x02 \x6b \x31 \x6b \x32 \x76 \x31 \x76 \x32 " ) ;
163
163
164
164
let s = r#"{"k":"v","a":"b"}"# ;
165
165
let value = parse_value ( s. as_bytes ( ) ) . unwrap ( ) ;
166
166
assert ! ( value. is_object( ) ) ;
167
167
168
168
let mut buf: Vec < u8 > = Vec :: new ( ) ;
169
- value. to_writer ( & mut buf) . unwrap ( ) ;
169
+ value. to_vec ( & mut buf) . unwrap ( ) ;
170
170
assert_eq ! (
171
171
buf,
172
172
b"\x40 \0 \0 \x02 \x10 \0 \0 \x01 \x10 \0 \0 \x01 \x10 \0 \0 \x01 \x10 \0 \0 \x01 \x61 \x6b \x62 \x76 "
0 commit comments