@@ -178,9 +178,9 @@ impl Value {
178
178
/// let value = Value::Text(String::from("hello"));
179
179
///
180
180
/// // We can read the String
181
- /// assert_eq!(value.as_text().unwrap(), &String::from( "hello") );
181
+ /// assert_eq!(value.as_text().unwrap(), "hello");
182
182
/// ```
183
- pub fn as_text ( & self ) -> Option < & String > {
183
+ pub fn as_text ( & self ) -> Option < & str > {
184
184
match * self {
185
185
Value :: Text ( ref s) => Some ( s) ,
186
186
_ => None ,
@@ -205,23 +205,6 @@ impl Value {
205
205
}
206
206
}
207
207
208
- /// If the `Value` is a `Text`, returns the associated `String` as an `&str`. Returns None
209
- /// otherwise.
210
- ///
211
- /// ```
212
- /// # use ciborium::value::Value;
213
- /// #
214
- /// let value = Value::Text(String::from("hello"));
215
- ///
216
- /// assert_eq!(value.as_str().unwrap(), "hello");
217
- /// ```
218
- pub fn as_str ( & self ) -> Option < & str > {
219
- match * self {
220
- Value :: Text ( ref s) => Some ( s. as_str ( ) ) ,
221
- _ => None ,
222
- }
223
- }
224
-
225
208
/// Returns true if the `Value` is a `Bool`. Returns false otherwise.
226
209
///
227
210
/// ```
@@ -287,12 +270,12 @@ impl Value {
287
270
/// let value = Value::Tag(61, Box::from(Value::Bytes(vec![104, 101, 108, 108, 111])));
288
271
///
289
272
/// let (tag, data) = value.as_tag().unwrap();
290
- /// assert_eq!(tag, & 61);
273
+ /// assert_eq!(tag, 61);
291
274
/// assert_eq!(data, &Value::Bytes(vec![104, 101, 108, 108, 111]));
292
275
/// ```
293
- pub fn as_tag ( & self ) -> Option < ( & u64 , & Value ) > {
294
- match & * self {
295
- Value :: Tag ( ref tag, data) => Some ( ( tag, data) ) ,
276
+ pub fn as_tag ( & self ) -> Option < ( u64 , & Value ) > {
277
+ match self {
278
+ Value :: Tag ( tag, data) => Some ( ( * tag, data) ) ,
296
279
_ => None ,
297
280
}
298
281
}
@@ -310,9 +293,9 @@ impl Value {
310
293
/// assert_eq!(tag, &61);
311
294
/// assert_eq!(data, &Value::Bytes(vec![]));
312
295
/// ```
313
- pub fn as_tag_mut ( & mut self ) -> Option < ( & u64 , & mut Value ) > {
314
- match * self {
315
- Value :: Tag ( ref tag, ref mut data) => Some ( ( tag, data. as_mut ( ) ) ) ,
296
+ pub fn as_tag_mut ( & mut self ) -> Option < ( & mut u64 , & mut Value ) > {
297
+ match self {
298
+ Value :: Tag ( tag, data) => Some ( ( tag, data. as_mut ( ) ) ) ,
316
299
_ => None ,
317
300
}
318
301
}
0 commit comments