File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ macro_rules! bson {
181
181
// Any Into<Bson> type.
182
182
// Must be below every other rule.
183
183
( $other: expr) => {
184
- $crate:: Bson :: from ( $other)
184
+ <_ as :: std :: convert :: Into < $crate:: Bson >> :: into ( $other)
185
185
} ;
186
186
}
187
187
@@ -392,7 +392,7 @@ macro_rules! rawbson {
392
392
// Any Into<RawBson> type.
393
393
// Must be below every other rule.
394
394
( $other: expr) => {
395
- $crate:: RawBson :: from ( $other)
395
+ <_ as :: std :: convert :: Into < $crate:: RawBson >> :: into ( $other)
396
396
} ;
397
397
}
398
398
Original file line number Diff line number Diff line change @@ -242,3 +242,34 @@ fn recursive_macro() {
242
242
243
243
assert_eq ! ( rawdoc. into_bytes( ) , crate :: to_vec( & doc) . unwrap( ) ) ;
244
244
}
245
+
246
+ #[ test]
247
+ #[ allow( clippy:: from_over_into) ]
248
+ fn can_use_macro_with_into_bson ( ) {
249
+ struct Custom ;
250
+
251
+ impl Into < Bson > for Custom {
252
+ fn into ( self ) -> Bson {
253
+ "foo" . into ( )
254
+ }
255
+ }
256
+
257
+ impl Into < RawBson > for Custom {
258
+ fn into ( self ) -> RawBson {
259
+ "foo" . into ( )
260
+ }
261
+ }
262
+
263
+ _ = bson ! ( {
264
+ "a" : Custom ,
265
+ } ) ;
266
+ _ = doc ! {
267
+ "a" : Custom ,
268
+ } ;
269
+ _ = rawbson ! ( {
270
+ "a" : Custom ,
271
+ } ) ;
272
+ _ = rawdoc ! {
273
+ "a" : Custom ,
274
+ } ;
275
+ }
You can’t perform that action at this time.
0 commit comments