@@ -317,7 +317,7 @@ impl ValueExt for Value {
317
317
Value :: Text ( _) => ( ) ,
318
318
Value :: Bool ( _) => ( ) ,
319
319
Value :: Null => ( ) ,
320
- Value :: Tag ( _, deref ! ( value) ) => value. canonicalize ( ) ,
320
+ Value :: Tag ( _, value) => value. canonicalize ( ) ,
321
321
Value :: Array ( array) => {
322
322
for value in array. iter_mut ( ) {
323
323
value. canonicalize ( ) ;
@@ -345,7 +345,7 @@ impl ValueExt for Value {
345
345
Value :: Text ( _) => true ,
346
346
Value :: Bool ( _) => true ,
347
347
Value :: Null => true ,
348
- Value :: Tag ( _, deref ! ( value) ) => value. is_canonical ( ) ,
348
+ Value :: Tag ( _, value) => value. is_canonical ( ) ,
349
349
Value :: Array ( array) => array. iter ( ) . all ( Self :: is_canonical) ,
350
350
Value :: Map ( map) => {
351
351
for [ ( a_key, _) , ( b_key, _) ] in map. array_windows ( ) {
@@ -374,14 +374,28 @@ impl ValueExt for Value {
374
374
}
375
375
376
376
fn as_datetime ( & self ) -> Option < DateTime < FixedOffset > > {
377
- let string = match self {
378
- Value :: Tag ( tag, deref ! ( Value :: Text ( string) ) )
379
- if * tag == iana:: CborTag :: DateTime as u64 =>
380
- {
381
- string
382
- }
383
- _ => return None ,
377
+ // A shorthand that requires deref patterns.
378
+ // let string = match self {
379
+ // Value::Tag(tag, deref!(Value::Text(string)))
380
+ // if *tag == iana::CborTag::DateTime as u64 =>
381
+ // {
382
+ // string
383
+ // }
384
+ // _ => return None,
385
+ // };
386
+
387
+ let Value :: Tag ( tag, inner) = self else {
388
+ return None ;
389
+ } ;
390
+
391
+ if * tag != iana:: CborTag :: DateTime as u64 {
392
+ return None ;
393
+ }
394
+
395
+ let Value :: Text ( string) = & * * inner else {
396
+ return None ;
384
397
} ;
398
+
385
399
let date_time = DateTime :: parse_from_rfc3339 ( string) . ok ( ) ?;
386
400
387
401
Some ( date_time)
0 commit comments