Skip to content

Commit

Permalink
Minor changes to placate clippy (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
gallagher-sdx authored Jan 16, 2024
1 parent 9169118 commit 178b12a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ regex = "1.5"
thiserror = "1.0"

[dev-dependencies]
criterion = "0.3"
criterion = "0.5"

[[bench]]
name = "simple_parse"
harness = false

[[bench]]
name = "decoder"
harness = false
harness = false
8 changes: 4 additions & 4 deletions src/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl<'a> Field<'a> {
) -> Result<Option<Field<'a>>, Hl7ParseError> {
match input {
None => Ok(None),
Some(x) if x.is_empty() => Ok(None),
Some("") => Ok(None),
Some(x) => Ok(Some(Field::parse(x, delims)?)),
}
}
Expand Down Expand Up @@ -106,22 +106,22 @@ impl<'a> Field<'a> {
if parts.len() == 1 {
let stringnums = parts[0]
.chars()
.filter(|c| c.is_digit(10))
.filter(|c| c.is_ascii_digit())
.collect::<String>();
let idx: usize = stringnums.parse().unwrap();

self[idx - 1]
} else if parts.len() == 2 {
let stringnums = parts[0]
.chars()
.filter(|c| c.is_digit(10))
.filter(|c| c.is_ascii_digit())
.collect::<String>();

let idx0: usize = stringnums.parse().unwrap();

let stringnums = parts[1]
.chars()
.filter(|c| c.is_digit(10))
.filter(|c| c.is_ascii_digit())
.collect::<String>();

let idx1: usize = stringnums.parse().unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/segments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ impl<'a> Segment<'a> {
1 => {
let stringnum = sections[0]
.chars()
.filter(|c| c.is_digit(10))
.filter(|c| c.is_ascii_digit())
.collect::<String>();
let idx: usize = stringnum.parse().unwrap();
self[idx]
}
_ => {
let stringnum = sections[0]
.chars()
.filter(|c| c.is_digit(10))
.filter(|c| c.is_ascii_digit())
.collect::<String>();
let idx: usize = stringnum.parse().unwrap();
if idx > self.fields.len() - 1 {
Expand Down
9 changes: 6 additions & 3 deletions src/separators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ pub struct Separators {
pub escape_char: char,
}

impl Separators {
/// Create a Separator with the default (most common) HL7 values
pub fn default() -> Separators {
impl Default for Separators {
/// Create a Separator with the default (most common) HL7 values
fn default() -> Separators {
Separators {
segment: '\r',
field: '|',
Expand All @@ -33,6 +33,9 @@ impl Separators {
escape_char: '\\',
}
}
}

impl Separators {

// Create a Separators with the values provided in the message.
// This assumes the message starts with `MSH|^~\&|` or equiv for custom Separators
Expand Down

0 comments on commit 178b12a

Please sign in to comment.