Content-Length: 441273 | pFad | http://github.com/adamcrume/java-properties/commit/b073d8d7e16ebaf8cd726ec2c04914c70c16c0b6

09 Fix Clippy lints · adamcrume/java-properties@b073d8d · GitHub
Skip to content

Commit b073d8d

Browse files
committed
Fix Clippy lints
1 parent 7104591 commit b073d8d

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

src/lib.rs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ impl Error for PropertiesError {
105105
&self.description
106106
}
107107

108+
// The "readable" version is less readable, especially since it requires manual type assertions.
109+
#[allow(clippy::manual_map)]
108110
fn source(&self) -> Option<&(dyn Error + 'static)> {
109111
match self.cause {
110112
Some(ref c) => Some(c.deref()),
@@ -324,12 +326,6 @@ impl Line {
324326
}
325327
}
326328

327-
impl Into<LineContent> for Line {
328-
fn into(self) -> LineContent {
329-
self.data
330-
}
331-
}
332-
333329
impl Display for Line {
334330
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
335331
write!(f, "Line {{line_number: {}, content: {}}}", self.line_number, self.data)
@@ -348,13 +344,19 @@ pub enum LineContent {
348344

349345
impl Display for LineContent {
350346
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
351-
match self {
352-
&LineContent::Comment(ref s) => write!(f, "Comment({:?})", s),
353-
&LineContent::KVPair(ref k, ref v) => write!(f, "KVPair({:?}, {:?})", k, v),
347+
match *self {
348+
LineContent::Comment(ref s) => write!(f, "Comment({:?})", s),
349+
LineContent::KVPair(ref k, ref v) => write!(f, "KVPair({:?}, {:?})", k, v),
354350
}
355351
}
356352
}
357353

354+
impl From<Line> for LineContent {
355+
fn from(line: Line) -> LineContent {
356+
line.data
357+
}
358+
}
359+
358360
//github.com///github.com///github.com///github.com///github.com///github.com///github.com/
359361

360362
fn unescape(s: &str, line_number: usize) -> Result<String, PropertiesError> {
@@ -440,15 +442,15 @@ lazy_static! {
440442
").unwrap();
441443
}
442444

443-
fn parse_line<'a>(line: &'a str) -> Option<ParsedLine<'a>> {
445+
fn parse_line(line: &str) -> Option<ParsedLine> {
444446
if let Some(c) = LINE_RE.captures(line) {
445447
if let Some(comment_match) = c.get(1) {
446448
Some(ParsedLine::Comment(comment_match.as_str()))
447449
} else if let Some(key_match) = c.get(2) {
448450
let key = key_match.as_str();
449451
if let Some(value_match) = c.get(3) {
450452
Some(ParsedLine::KVPair(key, value_match.as_str()))
451-
} else if key != "" {
453+
} else if !key.is_empty() {
452454
Some(ParsedLine::KVPair(key, ""))
453455
} else {
454456
None
@@ -524,9 +526,8 @@ impl<R: Read> Iterator for PropertiesIter<R> {
524526
fn next(&mut self) -> Option<Self::Item> {
525527
loop {
526528
match self.lines.next() {
527-
Some(Ok(LogicalLine(line_no, line))) => match parse_line(&line) {
528-
Some(parsed_line) => return Some(self.parsed_line_to_line(parsed_line, line_no)),
529-
None => (), // empty line, continue
529+
Some(Ok(LogicalLine(line_no, line))) => if let Some(parsed_line) = parse_line(&line) {
530+
return Some(self.parsed_line_to_line(parsed_line, line_no));
530531
},
531532
Some(Err(e)) => return Some(Err(e)),
532533
None => return None,
@@ -554,15 +555,17 @@ pub enum LineEnding {
554555
//github.com/ Line feed alone.
555556
LF,
556557
//github.com/ Carriage return followed by line feed.
558+
// The name can't be changed without breaking backward compatibility.
559+
#[allow(clippy::upper_case_acronyms)]
557560
CRLF,
558561
}
559562

560563
impl Display for LineEnding {
561564
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
562-
f.write_str(match self {
563-
&LineEnding::CR => "LineEnding::CR",
564-
&LineEnding::LF => "LineEnding::LF",
565-
&LineEnding::CRLF => "LineEnding::CRLF",
565+
f.write_str(match *self {
566+
LineEnding::CR => "LineEnding::CR",
567+
LineEnding::LF => "LineEnding::LF",
568+
LineEnding::CRLF => "LineEnding::CRLF",
566569
})
567570
}
568571
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/adamcrume/java-properties/commit/b073d8d7e16ebaf8cd726ec2c04914c70c16c0b6

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy