Skip to content

Commit

Permalink
fastq/record: Remove fmt::Display
Browse files Browse the repository at this point in the history
Write a record using `io::Writer` instead.
  • Loading branch information
zaeleus committed Jul 11, 2024
1 parent d8274f8 commit 6a71665
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 47 deletions.
8 changes: 8 additions & 0 deletions noodles-fastq/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## Unreleased

### Removed

* fastq/record: Remove `fmt::Display`.

Write a record using `io::Writer` instead.

## 0.12.0 - 2024-06-17

### Added
Expand Down
47 changes: 0 additions & 47 deletions noodles-fastq/src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ mod definition;

pub use self::definition::Definition;

use std::fmt;

/// A FASTQ record.
#[derive(Clone, Default, Debug, Eq, PartialEq)]
pub struct Record {
Expand Down Expand Up @@ -167,55 +165,10 @@ impl Record {
}
}

impl fmt::Display for Record {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("@")?;

for &b in self.name() {
write!(f, "{}", b as char)?;
}

if !self.description().is_empty() {
write!(f, " ")?;

for &b in self.description() {
write!(f, "{}", b as char)?;
}
}

writeln!(f)?;

for &b in self.sequence() {
write!(f, "{}", b as char)?;
}

writeln!(f)?;

writeln!(f, "+")?;

for &b in self.quality_scores() {
write!(f, "{}", b as char)?;
}

writeln!(f)?;

Ok(())
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_fmt() {
let mut record = Record::new(Definition::new("r0", ""), "ATCG", "NDLS");
assert_eq!(record.to_string(), "@r0\nATCG\n+\nNDLS\n");

record.description_mut().extend_from_slice(b"LN:4");
assert_eq!(record.to_string(), "@r0 LN:4\nATCG\n+\nNDLS\n");
}

#[test]
fn test_clear() {
let mut record = Record::new(Definition::new("r0", ""), "AGCT", "NDLS");
Expand Down

0 comments on commit 6a71665

Please sign in to comment.