File tree 2 files changed +26
-6
lines changed
2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -181,6 +181,26 @@ impl RawDocument {
181
181
Ok ( None )
182
182
}
183
183
184
+ /// Gets an iterator over the elements in the [`RawDocument`] that yields
185
+ /// `Result<(&str, RawBson<'_>)>`.
186
+ pub fn iter ( & self ) -> Iter < ' _ > {
187
+ Iter :: new ( self )
188
+ }
189
+
190
+ /// Gets an iterator over the elements in the [`RawDocument`],
191
+ /// which yields `Result<RawElement<'_>>` values. These hold a
192
+ /// reference to the underlying document but do not explicitly
193
+ /// resolve the values.
194
+ ///
195
+ /// This iterator, which underpins the implementation of the
196
+ /// default iterator, produces `RawElement` objects that hold a
197
+ /// view onto the document but do not parse out or construct
198
+ /// values until the `.value()` or `.try_into()` methods are
199
+ /// called.
200
+ pub fn iter_elements ( & self ) -> RawIter < ' _ > {
201
+ RawIter :: new ( self )
202
+ }
203
+
184
204
fn get_with < ' a , T > (
185
205
& ' a self ,
186
206
key : impl AsRef < str > ,
@@ -599,6 +619,6 @@ impl<'a> IntoIterator for &'a RawDocument {
599
619
type Item = Result < ( & ' a str , RawBsonRef < ' a > ) > ;
600
620
601
621
fn into_iter ( self ) -> Iter < ' a > {
602
- Iter :: new ( self )
622
+ self . iter ( )
603
623
}
604
624
}
Original file line number Diff line number Diff line change @@ -157,10 +157,10 @@ impl RawDocumentBuf {
157
157
/// resolve the values.
158
158
///
159
159
/// This iterator, which underpins the implementation of the
160
- /// default iterator, produces `RawElement` objects, which
161
- /// hold a view onto the document but do not parse out or
162
- /// construct values until the `.value()` or `.try_into()` methods
163
- /// are called.
160
+ /// default iterator, produces `RawElement` objects that hold a
161
+ /// view onto the document but do not parse out or construct
162
+ /// values until the `.value()` or `.try_into()` methods are
163
+ /// called.
164
164
///
165
165
/// # Note:
166
166
///
@@ -394,7 +394,7 @@ impl<'a> IntoIterator for &'a RawDocumentBuf {
394
394
type Item = Result < ( & ' a str , RawBsonRef < ' a > ) > ;
395
395
396
396
fn into_iter ( self ) -> Iter < ' a > {
397
- Iter :: new ( self )
397
+ self . iter ( )
398
398
}
399
399
}
400
400
You can’t perform that action at this time.
0 commit comments