Skip to content

Commit

Permalink
sam/io/reader: Add example for Reader::records
Browse files Browse the repository at this point in the history
  • Loading branch information
zaeleus committed Mar 25, 2024
1 parent c3f9878 commit 59d8097
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions noodles-sam/src/io/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,25 @@ where
///
/// The stream is expected to be directly after the reference sequences or at the start of
/// another record.
///
/// # Examples
///
/// ```
/// use noodles_sam as sam;
///
/// let data = b"@HD\tVN:1.6
/// *\t4\t*\t0\t255\t*\t*\t0\t0\t*\t*
/// ";
///
/// let mut reader = sam::io::Reader::new(&data[..]);
/// reader.read_header()?;
///
/// for result in reader.records() {
/// let record = result?;
/// // ...
/// }
/// # Ok::<_, std::io::Error>(())
/// ```
pub fn records(&mut self) -> impl Iterator<Item = io::Result<Record>> + '_ {
let mut record = Record::default();

Expand Down

0 comments on commit 59d8097

Please sign in to comment.