Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ReagentX committed Nov 30, 2023
1 parent 8a95eb2 commit 039a75b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
6 changes: 6 additions & 0 deletions imessage-database/src/message_types/handwriting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@ impl HandwrittenMessage {
Self {}
}
}

impl Default for HandwrittenMessage {
fn default() -> Self {
Self::new()
}
}
24 changes: 12 additions & 12 deletions imessage-exporter/src/app/export_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ use std::fmt::Display;
#[derive(PartialEq, Eq, Debug)]
pub enum ExportType {
/// HTML file export
HTML,
Html,
/// Text file export
TXT,
Txt,
}

impl ExportType {
/// Given user's input, return a variant if the input matches one
pub fn from_cli(platform: &str) -> Option<Self> {
match platform.to_lowercase().as_str() {
"txt" => Some(Self::TXT),
"html" => Some(Self::HTML),
"txt" => Some(Self::Txt),
"html" => Some(Self::Html),
_ => None,
}
}
Expand All @@ -27,8 +27,8 @@ impl ExportType {
impl Display for ExportType {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ExportType::TXT => write!(fmt, "txt"),
ExportType::HTML => write!(fmt, "html"),
ExportType::Txt => write!(fmt, "txt"),
ExportType::Html => write!(fmt, "html"),
}
}
}
Expand All @@ -41,23 +41,23 @@ mod tests {
fn can_parse_html_any_case() {
assert!(matches!(
ExportType::from_cli("html"),
Some(ExportType::HTML)
Some(ExportType::Html)
));
assert!(matches!(
ExportType::from_cli("HTML"),
Some(ExportType::HTML)
Some(ExportType::Html)
));
assert!(matches!(
ExportType::from_cli("HtMl"),
Some(ExportType::HTML)
Some(ExportType::Html)
));
}

#[test]
fn can_parse_txt_any_case() {
assert!(matches!(ExportType::from_cli("txt"), Some(ExportType::TXT)));
assert!(matches!(ExportType::from_cli("TXT"), Some(ExportType::TXT)));
assert!(matches!(ExportType::from_cli("tXt"), Some(ExportType::TXT)));
assert!(matches!(ExportType::from_cli("txt"), Some(ExportType::Txt)));
assert!(matches!(ExportType::from_cli("TXT"), Some(ExportType::Txt)));
assert!(matches!(ExportType::from_cli("tXt"), Some(ExportType::Txt)));
}

#[test]
Expand Down
10 changes: 5 additions & 5 deletions imessage-exporter/src/app/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ mod arg_tests {
attachment_root: None,
attachment_manager: AttachmentManager::default(),
diagnostic: false,
export_type: Some(ExportType::HTML),
export_type: Some(ExportType::Html),
export_path: validate_path(Some(&tmp_dir), &None).unwrap(),
query_context: QueryContext::default(),
no_lazy: false,
Expand Down Expand Up @@ -537,7 +537,7 @@ mod arg_tests {
attachment_root: None,
attachment_manager: AttachmentManager::default(),
diagnostic: false,
export_type: Some(ExportType::TXT),
export_type: Some(ExportType::Txt),
export_path: validate_path(None, &None).unwrap(),
query_context: QueryContext::default(),
no_lazy: true,
Expand Down Expand Up @@ -657,7 +657,7 @@ mod path_tests {
fn can_validate_empty() {
let tmp = String::from("/tmp");
let export_path = Some(&tmp);
let export_type = Some(ExportType::TXT);
let export_type = Some(ExportType::Txt);

let result = validate_path(export_path, &export_type.as_ref());

Expand All @@ -668,7 +668,7 @@ mod path_tests {
fn can_validate_different_type() {
let tmp = String::from("/tmp");
let export_path = Some(&tmp);
let export_type = Some(ExportType::TXT);
let export_type = Some(ExportType::Txt);

let result = validate_path(export_path, &export_type.as_ref());

Expand All @@ -685,7 +685,7 @@ mod path_tests {
fn can_validate_same_type() {
let tmp = String::from("/tmp");
let export_path = Some(&tmp);
let export_type = Some(ExportType::TXT);
let export_type = Some(ExportType::Txt);

let result = validate_path(export_path, &export_type.as_ref());

Expand Down
4 changes: 2 additions & 2 deletions imessage-exporter/src/app/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ impl Config {

// Create exporter, pass it data we care about, then kick it off
match export_type {
ExportType::HTML => {
ExportType::Html => {
HTML::new(self).iter_messages()?;
}
ExportType::TXT => {
ExportType::Txt => {
TXT::new(self).iter_messages()?;
}
}
Expand Down

0 comments on commit 039a75b

Please sign in to comment.