@@ -209,15 +209,15 @@ impl<'a> RawBson<'a> {
209
209
210
210
/// Gets the BSON JavaScript code with scope that's referenced or returns an error if the value
211
211
/// isn't BSON JavaScript code with scope.
212
- pub fn as_javascript_with_scope ( self ) -> RawResult < ( & ' a str , & ' a RawDocumentRef ) > {
212
+ pub fn as_javascript_with_scope ( self ) -> RawResult < RawJavaScriptCodeWithScope < ' a > > {
213
213
if let ElementType :: JavaScriptCodeWithScope = self . element_type {
214
214
let length = i32_from_slice ( & self . data [ ..4 ] ) ;
215
215
assert_eq ! ( self . data. len( ) as i32 , length) ;
216
216
217
- let js = read_lenencoded ( & self . data [ 4 ..] ) ?;
218
- let doc = RawDocumentRef :: new ( & self . data [ 9 + js . len ( ) ..] ) ?;
217
+ let code = read_lenencoded ( & self . data [ 4 ..] ) ?;
218
+ let scope = RawDocumentRef :: new ( & self . data [ 9 + code . len ( ) ..] ) ?;
219
219
220
- Ok ( ( js , doc ) )
220
+ Ok ( RawJavaScriptCodeWithScope { code , scope } )
221
221
} else {
222
222
Err ( RawError :: UnexpectedType )
223
223
}
@@ -318,9 +318,10 @@ impl<'a> TryFrom<RawBson<'a>> for Bson {
318
318
ElementType :: DbPointer => panic ! ( "Uh oh. Maybe this should be a TryFrom" ) ,
319
319
ElementType :: Symbol => Bson :: Symbol ( String :: from ( rawbson. as_symbol ( ) ?) ) ,
320
320
ElementType :: JavaScriptCodeWithScope => {
321
- let ( js, scope) = rawbson. as_javascript_with_scope ( ) ?;
321
+ let RawJavaScriptCodeWithScope { code, scope } =
322
+ rawbson. as_javascript_with_scope ( ) ?;
322
323
Bson :: JavaScriptCodeWithScope ( crate :: JavaScriptCodeWithScope {
323
- code : String :: from ( js ) ,
324
+ code : String :: from ( code ) ,
324
325
scope : scope. try_into ( ) ?,
325
326
} )
326
327
}
0 commit comments