Skip to content

Commit 5c5f6d3

Browse files
authored
docs: Clarify reference end position documentation (#491)
* docs: Clarify reference end position documentation * refactor: Add explicit lifetimes to iterator return types * refactor: Use is_multiple_of for clarity
1 parent d42f23f commit 5c5f6d3

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/bam/buffer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ impl RecordBuffer {
157157
}
158158

159159
/// Iterate over records that have been fetched with `fetch`.
160-
pub fn iter(&self) -> vec_deque::Iter<Rc<bam::Record>> {
160+
pub fn iter(&self) -> vec_deque::Iter<'_, Rc<bam::Record>> {
161161
self.inner.iter()
162162
}
163163

164164
/// Iterate over mutable references to records that have been fetched with `fetch`.
165-
pub fn iter_mut(&mut self) -> vec_deque::IterMut<Rc<bam::Record>> {
165+
pub fn iter_mut(&mut self) -> vec_deque::IterMut<'_, Rc<bam::Record>> {
166166
self.inner.iter_mut()
167167
}
168168

src/bam/ext.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ pub trait BamRecordExtensions {
301301
/// left most aligned reference position of the read on the reference genome.
302302
fn reference_start(&self) -> i64;
303303

304-
/// right most aligned reference position of the read on the reference genome.
304+
/// right most aligned absolute reference position of the read on the reference genome.
305305
fn reference_end(&self) -> i64;
306306

307307
/// infer the query length from the cigar string, optionally include hard clipped bases
@@ -435,7 +435,7 @@ impl BamRecordExtensions for bam::Record {
435435
self.pos()
436436
}
437437

438-
/// Calculate the rightmost base position of an alignment on the reference genome.
438+
/// Calculate the rightmost absolute reference base position of an alignment on the reference genome.
439439
/// Returns the coordinate of the first base after the alignment (0-based).
440440
fn reference_end(&self) -> i64 {
441441
unsafe { htslib::bam_endpos(self.inner_ptr()) }

src/bam/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl Header {
106106
}
107107

108108
/// Returns an iterator of comment lines.
109-
pub fn comments(&self) -> impl Iterator<Item = Cow<str>> {
109+
pub fn comments(&self) -> impl Iterator<Item = Cow<'_, str>> {
110110
self.records.iter().flat_map(|r| {
111111
r.split(|x| x == &b'\n')
112112
.filter(|x| x.starts_with(b"@CO\t"))

src/bam/record.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl Default for Record {
103103
#[inline]
104104
fn extranul_from_qname(qname: &[u8]) -> usize {
105105
let qlen = qname.len() + 1;
106-
if qlen % 4 != 0 {
106+
if !qlen.is_multiple_of(4) {
107107
4 - qlen % 4
108108
} else {
109109
0
@@ -833,7 +833,7 @@ impl Record {
833833
///
834834
/// When an error occurs, the `Err` variant will be returned
835835
/// and the iterator will not be able to advance anymore.
836-
pub fn aux_iter(&self) -> AuxIter {
836+
pub fn aux_iter(&self) -> AuxIter<'_> {
837837
AuxIter {
838838
// In order to get to the aux data section of a `bam::Record`
839839
// we need to skip fields in front of it
@@ -1272,14 +1272,14 @@ impl Record {
12721272
/// }
12731273
/// assert_eq!(mod_count, 14);
12741274
/// ```
1275-
pub fn basemods_iter(&self) -> Result<BaseModificationsIter> {
1275+
pub fn basemods_iter(&self) -> Result<BaseModificationsIter<'_>> {
12761276
BaseModificationsIter::new(self)
12771277
}
12781278

12791279
/// An iterator that returns all of the modifications for each position as a vector.
12801280
/// This is useful for the case where multiple possible modifications can be annotated
12811281
/// at a single position (for example a C could be 5-mC or 5-hmC)
1282-
pub fn basemods_position_iter(&self) -> Result<BaseModificationsPositionIter> {
1282+
pub fn basemods_position_iter(&self) -> Result<BaseModificationsPositionIter<'_>> {
12831283
BaseModificationsPositionIter::new(self)
12841284
}
12851285

@@ -1658,7 +1658,7 @@ where
16581658
}
16591659

16601660
/// Returns an iterator over the array.
1661-
pub fn iter(&self) -> AuxArrayIter<T> {
1661+
pub fn iter(&self) -> AuxArrayIter<'_, T> {
16621662
AuxArrayIter {
16631663
index: 0,
16641664
array: self,

0 commit comments

Comments
 (0)