@@ -199,7 +199,7 @@ impl<'b> serde::Serializer for &'b mut ValueSerializer<'_> {
199199 let increment = u32:: try_from ( v) . map_err ( Error :: custom) ?;
200200
201201 RawBsonRef :: Timestamp ( crate :: Timestamp { time, increment } )
202- . append_to ( & mut self . root_serializer . bytes ) ? ;
202+ . append_to ( & mut self . root_serializer . bytes ) ;
203203
204204 Ok ( ( ) )
205205 }
@@ -215,7 +215,7 @@ impl<'b> serde::Serializer for &'b mut ValueSerializer<'_> {
215215 subtype : v. into ( ) ,
216216 bytes,
217217 } ;
218- RawBsonRef :: Binary ( binary) . append_to ( & mut self . root_serializer . bytes ) ? ;
218+ RawBsonRef :: Binary ( binary) . append_to ( & mut self . root_serializer . bytes ) ;
219219 self . state = SerializationStep :: Done ;
220220 Ok ( ( ) )
221221 }
@@ -258,11 +258,11 @@ impl<'b> serde::Serializer for &'b mut ValueSerializer<'_> {
258258 SerializationStep :: DateTimeNumberLong => {
259259 let millis = v. parse ( ) . map_err ( Error :: custom) ?;
260260 RawBsonRef :: DateTime ( crate :: DateTime :: from_millis ( millis) )
261- . append_to ( & mut self . root_serializer . bytes ) ? ;
261+ . append_to ( & mut self . root_serializer . bytes ) ;
262262 }
263263 SerializationStep :: Oid => {
264264 let oid = ObjectId :: parse_str ( v) . map_err ( Error :: custom) ?;
265- RawBsonRef :: ObjectId ( oid) . append_to ( & mut self . root_serializer . bytes ) ? ;
265+ RawBsonRef :: ObjectId ( oid) . append_to ( & mut self . root_serializer . bytes ) ;
266266 }
267267 SerializationStep :: BinaryBytes => {
268268 self . state = SerializationStep :: BinarySubType {
@@ -274,18 +274,18 @@ impl<'b> serde::Serializer for &'b mut ValueSerializer<'_> {
274274 let subtype: BinarySubtype = subtype_byte[ 0 ] . into ( ) ;
275275 let bytes = & base64:: decode ( base64. as_str ( ) ) . map_err ( Error :: custom) ?;
276276 let binary = RawBinaryRef { subtype, bytes } ;
277- RawBsonRef :: Binary ( binary) . append_to ( & mut self . root_serializer . bytes ) ? ;
277+ RawBsonRef :: Binary ( binary) . append_to ( & mut self . root_serializer . bytes ) ;
278278 }
279279 SerializationStep :: Symbol => {
280- RawBsonRef :: Symbol ( v) . append_to ( & mut self . root_serializer . bytes ) ? ;
280+ RawBsonRef :: Symbol ( v) . append_to ( & mut self . root_serializer . bytes ) ;
281281 }
282282 SerializationStep :: DbPointerRef => {
283283 self . state = SerializationStep :: DbPointerId { ns : v. to_owned ( ) } ;
284284 }
285285 SerializationStep :: DbPointerId { ns } => {
286286 let id = ObjectId :: parse_str ( v) . map_err ( Error :: custom) ?;
287287 RawBsonRef :: DbPointer ( crate :: RawDbPointerRef { namespace : ns, id } )
288- . append_to ( & mut self . root_serializer . bytes ) ? ;
288+ . append_to ( & mut self . root_serializer . bytes ) ;
289289 }
290290 SerializationStep :: RegExPattern => {
291291 self . state = SerializationStep :: RegExOptions {
@@ -301,10 +301,10 @@ impl<'b> serde::Serializer for &'b mut ValueSerializer<'_> {
301301 pattern : pattern. as_ref ( ) ,
302302 options : options. as_str ( ) . try_into ( ) ?,
303303 } )
304- . append_to ( & mut self . root_serializer . bytes ) ? ;
304+ . append_to ( & mut self . root_serializer . bytes ) ;
305305 }
306306 SerializationStep :: Code => {
307- RawBsonRef :: JavaScriptCode ( v) . append_to ( & mut self . root_serializer . bytes ) ? ;
307+ RawBsonRef :: JavaScriptCode ( v) . append_to ( & mut self . root_serializer . bytes ) ;
308308 }
309309 SerializationStep :: CodeWithScopeCode => {
310310 self . state = SerializationStep :: CodeWithScopeScope {
@@ -327,7 +327,7 @@ impl<'b> serde::Serializer for &'b mut ValueSerializer<'_> {
327327 match self . state {
328328 SerializationStep :: Decimal128Value => {
329329 let dec = crate :: Decimal128 :: from_bytes ( v. try_into ( ) . map_err ( Error :: custom) ?) ;
330- RawBsonRef :: Decimal128 ( dec) . append_to ( & mut self . root_serializer . bytes ) ? ;
330+ RawBsonRef :: Decimal128 ( dec) . append_to ( & mut self . root_serializer . bytes ) ;
331331 Ok ( ( ) )
332332 }
333333 SerializationStep :: BinaryBytes => {
@@ -339,8 +339,7 @@ impl<'b> serde::Serializer for &'b mut ValueSerializer<'_> {
339339 code,
340340 scope : RawDocument :: decode_from_bytes ( v) . map_err ( Error :: custom) ?,
341341 } ;
342- RawBsonRef :: JavaScriptCodeWithScope ( raw)
343- . append_to ( & mut self . root_serializer . bytes ) ?;
342+ RawBsonRef :: JavaScriptCodeWithScope ( raw) . append_to ( & mut self . root_serializer . bytes ) ;
344343 self . state = SerializationStep :: Done ;
345344 Ok ( ( ) )
346345 }
@@ -448,9 +447,9 @@ impl<'b> serde::Serializer for &'b mut ValueSerializer<'_> {
448447 #[ inline]
449448 fn serialize_map ( self , _len : Option < usize > ) -> Result < Self :: SerializeMap > {
450449 match self . state {
451- SerializationStep :: CodeWithScopeScope { ref code, raw } if !raw => {
452- CodeWithScopeSerializer :: start ( code. as_str ( ) , self . root_serializer )
453- }
450+ SerializationStep :: CodeWithScopeScope { ref code, raw } if !raw => Ok (
451+ CodeWithScopeSerializer :: start ( code. as_str ( ) , self . root_serializer ) ,
452+ ) ,
454453 _ => Err ( self . invalid_step ( "map" ) ) ,
455454 }
456455 }
@@ -613,13 +612,13 @@ pub(crate) struct CodeWithScopeSerializer<'a> {
613612
614613impl < ' a > CodeWithScopeSerializer < ' a > {
615614 #[ inline]
616- fn start ( code : & str , rs : & ' a mut Serializer ) -> Result < Self > {
615+ fn start ( code : & str , rs : & ' a mut Serializer ) -> Self {
617616 let start = rs. bytes . len ( ) ;
618- RawBsonRef :: Int32 ( 0 ) . append_to ( & mut rs. bytes ) ? ; // placeholder length
617+ RawBsonRef :: Int32 ( 0 ) . append_to ( & mut rs. bytes ) ; // placeholder length
619618 write_string ( & mut rs. bytes , code) ;
620619
621- let doc = DocumentSerializer :: start ( rs) ? ;
622- Ok ( Self { start, doc } )
620+ let doc = DocumentSerializer :: start ( rs) ;
621+ Self { start, doc }
623622 }
624623}
625624
0 commit comments