@@ -361,9 +361,7 @@ impl From<Bson> for Value {
361361impl Bson {
362362 /// Converts the Bson value into its [relaxed extended JSON representation](https://docs.mongodb.com/manual/reference/mongodb-extended-json/).
363363 ///
364- /// Note: extended json encoding for `Decimal128` values is not supported without the
365- /// "decimal128" feature flag. If this method is called on a case which contains a
366- /// `Decimal128` value, it will panic.
364+ /// Note: If this method is called on a case which contains a `Decimal128` value, it will panic.
367365 pub fn into_relaxed_extjson ( self ) -> Value {
368366 match self {
369367 Bson :: Double ( v) if v. is_nan ( ) => {
@@ -433,13 +431,7 @@ impl Bson {
433431 "$date" : { "$numberLong" : v. timestamp_millis( ) . to_string( ) } ,
434432 } ) ,
435433 Bson :: Symbol ( v) => json ! ( { "$symbol" : v } ) ,
436- #[ cfg( feature = "decimal128" ) ]
437- Bson :: Decimal128 ( ref v) => json ! ( { "$numberDecimal" : v. to_string( ) } ) ,
438- #[ cfg( not( feature = "decimal128" ) ) ]
439- Bson :: Decimal128 ( _) => panic ! (
440- "Decimal128 extended JSON not implemented yet. Use the decimal128 feature to \
441- enable experimental support for it."
442- ) ,
434+ Bson :: Decimal128 ( _) => panic ! ( "Decimal128 extended JSON not implemented yet." ) ,
443435 Bson :: Undefined => json ! ( { "$undefined" : true } ) ,
444436 Bson :: MinKey => json ! ( { "$minKey" : 1 } ) ,
445437 Bson :: MaxKey => json ! ( { "$maxKey" : 1 } ) ,
@@ -459,9 +451,8 @@ impl Bson {
459451
460452 /// Converts the Bson value into its [canonical extended JSON representation](https://docs.mongodb.com/manual/reference/mongodb-extended-json/).
461453 ///
462- /// Note: extended json encoding for `Decimal128` values is not supported without the
463- /// "decimal128" feature flag. If this method is called on a case which contains a
464- /// `Decimal128` value, it will panic.
454+ /// Note: extended json encoding for `Decimal128` values is not supported. If this method is
455+ /// called on a case which contains a `Decimal128` value, it will panic.
465456 pub fn into_canonical_extjson ( self ) -> Value {
466457 match self {
467458 Bson :: Int32 ( i) => json ! ( { "$numberInt" : i. to_string( ) } ) ,
@@ -594,12 +585,6 @@ impl Bson {
594585 "$symbol" : v. to_owned( ) ,
595586 }
596587 }
597- #[ cfg( feature = "decimal128" ) ]
598- Bson :: Decimal128 ( ref v) => {
599- doc ! {
600- "$numberDecimal" : ( v. to_string( ) )
601- }
602- }
603588 Bson :: Undefined => {
604589 doc ! {
605590 "$undefined" : true ,
@@ -683,25 +668,10 @@ impl Bson {
683668 _ => { }
684669 } ,
685670
686- #[ cfg( feature = "decimal128" ) ]
687- [ "$numberDecimal" ] => {
688- if let Ok ( d) = doc. get_str ( "$numberDecimal" ) {
689- if let Ok ( d) = d. parse ( ) {
690- return Bson :: Decimal128 ( d) ;
691- }
692- }
693- }
694-
695671 [ "$numberDecimalBytes" ] => {
696672 if let Ok ( bytes) = doc. get_binary_generic ( "$numberDecimalBytes" ) {
697673 if let Ok ( b) = bytes. clone ( ) . try_into ( ) {
698- #[ cfg( not( feature = "decimal128" ) ) ]
699674 return Bson :: Decimal128 ( Decimal128 { bytes : b } ) ;
700-
701- #[ cfg( feature = "decimal128" ) ]
702- unsafe {
703- return Bson :: Decimal128 ( Decimal128 :: from_raw_bytes_le ( b) ) ;
704- }
705675 }
706676 }
707677 }
0 commit comments