Skip to content

Commit

Permalink
Reformat code with cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
althonos committed Oct 4, 2023
1 parent 0614166 commit 54dfee6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl<B: BufRead + Send + 'static, D: UniprotDatabase> Iterator for ThreadedParse
if !self.producer.is_alive() {
self.state = State::Finished
}
},
}
// queue was disconnected: stop and return an error
Err(RecvTimeoutError::Disconnected) => {
if self.state != State::Finished {
Expand Down
18 changes: 5 additions & 13 deletions src/parser/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ enum State {
Finished,
}


#[cfg(feature = "threading")]
pub struct Producer<B> {
reader: Option<B>,
Expand All @@ -31,12 +30,7 @@ pub struct Producer<B> {
}

impl<B: BufRead + Send + 'static> Producer<B> {

pub(super) fn new(
reader: B,
threads: usize,
s_text: Sender<Option<Vec<u8>>>,
) -> Self {
pub(super) fn new(reader: B, threads: usize, s_text: Sender<Option<Vec<u8>>>) -> Self {
Self {
reader: Some(reader),
s_text,
Expand Down Expand Up @@ -82,15 +76,13 @@ impl<B: BufRead + Send + 'static> Producer<B> {
state = State::Finished;

Check warning on line 76 in src/parser/producer.rs

View workflow job for this annotation

GitHub Actions / Test (beta, --all-features)

unreachable statement

Check warning on line 76 in src/parser/producer.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, --all-features)

unreachable statement

Check warning on line 76 in src/parser/producer.rs

View workflow job for this annotation

GitHub Actions / Test (stable, --all-features)

unreachable statement
// return Some(Err(Error::from(e)));
}
}
},
State::Reading => {
// read until the end of the entry.
match reader.read_until(b'>', &mut buffer) {
// if a full entry is found, send it
Ok(_) if buffer.ends_with(&b"</entry>"[..]) => {
s_text
.send(Some(buffer.as_slice().to_vec()))
.ok();
s_text.send(Some(buffer.as_slice().to_vec())).ok();
state = State::Started;
buffer.clear();
}
Expand All @@ -115,7 +107,7 @@ impl<B: BufRead + Send + 'static> Producer<B> {
// otherwise just keep iterating.
_ => (),
}
}
}
State::AtEof | State::Finished => break,
_ => unimplemented!(),

Check warning on line 112 in src/parser/producer.rs

View workflow job for this annotation

GitHub Actions / Test (beta, --all-features)

unreachable pattern

Check warning on line 112 in src/parser/producer.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, --all-features)

unreachable pattern

Check warning on line 112 in src/parser/producer.rs

View workflow job for this annotation

GitHub Actions / Test (stable, --all-features)

unreachable pattern
}
Expand All @@ -135,4 +127,4 @@ impl<B: BufRead + Send + 'static> Producer<B> {
pub fn is_alive(&self) -> bool {
self.alive.load(Ordering::SeqCst)
}
}
}
2 changes: 1 addition & 1 deletion src/uniparc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn parse<B: BufRead + Send + 'static>(reader: B) -> Parser<B> {
///
/// println!("{:?}", entry);
/// ```
pub fn parse_entry<B: BufRead + Send+ 'static>(reader: B) -> <Parser<B> as Iterator>::Item {
pub fn parse_entry<B: BufRead + Send + 'static>(reader: B) -> <Parser<B> as Iterator>::Item {
SequentialParser::parse_entry(reader)
}

Expand Down
4 changes: 2 additions & 2 deletions src/uniprot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub type Parser<B> = super::parser::Parser<B, UniProt>;
///
/// println!("{:#?}", parser.next());
/// ```
pub fn parse<B: BufRead + Send+ 'static>(reader: B) -> Parser<B> {
pub fn parse<B: BufRead + Send + 'static>(reader: B) -> Parser<B> {
Parser::new(reader)
}

Expand All @@ -53,7 +53,7 @@ pub fn parse<B: BufRead + Send+ 'static>(reader: B) -> Parser<B> {
///
/// println!("{:?}", entry);
/// ```
pub fn parse_entry<B: BufRead + Send+ 'static>(reader: B) -> <Parser<B> as Iterator>::Item {
pub fn parse_entry<B: BufRead + Send + 'static>(reader: B) -> <Parser<B> as Iterator>::Item {
SequentialParser::parse_entry(reader)
}

Expand Down
4 changes: 2 additions & 2 deletions src/uniref/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ pub type Parser<B> = super::parser::Parser<B, UniRef>;
///
/// println!("{:?}", entry);
/// ```
pub fn parse<B: BufRead+Send+'static>(reader: B) -> Parser<B> {
pub fn parse<B: BufRead + Send + 'static>(reader: B) -> Parser<B> {
Parser::new(reader)
}

/// Parse a single UniRef entry.
pub fn parse_entry<B: BufRead+Send+'static>(reader: B) -> <Parser<B> as Iterator>::Item {
pub fn parse_entry<B: BufRead + Send + 'static>(reader: B) -> <Parser<B> as Iterator>::Item {
SequentialParser::parse_entry(reader)
}

Expand Down

0 comments on commit 54dfee6

Please sign in to comment.