@@ -2121,15 +2121,7 @@ where
2121
2121
2122
2122
/// Deserialize an instance of type `T` from an IO stream of JSON.
2123
2123
///
2124
- /// # Errors
2125
- ///
2126
- /// This conversion can fail if the structure of the input does not match the
2127
- /// structure expected by `T`, for example if `T` is a struct type but the input
2128
- /// contains something other than a JSON map. It can also fail if the structure
2129
- /// is correct but `T`'s implementation of `Deserialize` decides that something
2130
- /// is wrong with the data, for example required struct fields are missing from
2131
- /// the JSON map or some number is too big to fit in the expected primitive
2132
- /// type.
2124
+ /// # Example
2133
2125
///
2134
2126
/// ```rust
2135
2127
/// #[macro_use]
@@ -2166,15 +2158,6 @@ where
2166
2158
/// println!("{:#?}", u);
2167
2159
/// }
2168
2160
/// ```
2169
- pub fn from_reader < R , T > ( rdr : R ) -> Result < T >
2170
- where
2171
- R : io:: Read ,
2172
- T : de:: DeserializeOwned ,
2173
- {
2174
- from_trait ( read:: IoRead :: new ( rdr) )
2175
- }
2176
-
2177
- /// Deserialize an instance of type `T` from bytes of JSON text.
2178
2161
///
2179
2162
/// # Errors
2180
2163
///
@@ -2185,6 +2168,17 @@ where
2185
2168
/// is wrong with the data, for example required struct fields are missing from
2186
2169
/// the JSON map or some number is too big to fit in the expected primitive
2187
2170
/// type.
2171
+ pub fn from_reader < R , T > ( rdr : R ) -> Result < T >
2172
+ where
2173
+ R : io:: Read ,
2174
+ T : de:: DeserializeOwned ,
2175
+ {
2176
+ from_trait ( read:: IoRead :: new ( rdr) )
2177
+ }
2178
+
2179
+ /// Deserialize an instance of type `T` from bytes of JSON text.
2180
+ ///
2181
+ /// # Example
2188
2182
///
2189
2183
/// ```rust
2190
2184
/// #[macro_use]
@@ -2210,14 +2204,6 @@ where
2210
2204
/// println!("{:#?}", u);
2211
2205
/// }
2212
2206
/// ```
2213
- pub fn from_slice < ' a , T > ( v : & ' a [ u8 ] ) -> Result < T >
2214
- where
2215
- T : de:: Deserialize < ' a > ,
2216
- {
2217
- from_trait ( read:: SliceRead :: new ( v) )
2218
- }
2219
-
2220
- /// Deserialize an instance of type `T` from a string of JSON text.
2221
2207
///
2222
2208
/// # Errors
2223
2209
///
@@ -2228,6 +2214,16 @@ where
2228
2214
/// is wrong with the data, for example required struct fields are missing from
2229
2215
/// the JSON map or some number is too big to fit in the expected primitive
2230
2216
/// type.
2217
+ pub fn from_slice < ' a , T > ( v : & ' a [ u8 ] ) -> Result < T >
2218
+ where
2219
+ T : de:: Deserialize < ' a > ,
2220
+ {
2221
+ from_trait ( read:: SliceRead :: new ( v) )
2222
+ }
2223
+
2224
+ /// Deserialize an instance of type `T` from a string of JSON text.
2225
+ ///
2226
+ /// # Example
2231
2227
///
2232
2228
/// ```rust
2233
2229
/// #[macro_use]
@@ -2253,6 +2249,16 @@ where
2253
2249
/// println!("{:#?}", u);
2254
2250
/// }
2255
2251
/// ```
2252
+ ///
2253
+ /// # Errors
2254
+ ///
2255
+ /// This conversion can fail if the structure of the input does not match the
2256
+ /// structure expected by `T`, for example if `T` is a struct type but the input
2257
+ /// contains something other than a JSON map. It can also fail if the structure
2258
+ /// is correct but `T`'s implementation of `Deserialize` decides that something
2259
+ /// is wrong with the data, for example required struct fields are missing from
2260
+ /// the JSON map or some number is too big to fit in the expected primitive
2261
+ /// type.
2256
2262
pub fn from_str < ' a , T > ( s : & ' a str ) -> Result < T >
2257
2263
where
2258
2264
T : de:: Deserialize < ' a > ,
0 commit comments