diff --git a/src/context/constants.rs b/src/context/constants.rs index 011797b7..34bb98c7 100644 --- a/src/context/constants.rs +++ b/src/context/constants.rs @@ -1,15 +1,15 @@ use super::global_settings::EntityDefinition; -pub(crate) const DEFAULT_ORG_ELEMENT_PARSED_KEYWORDS: [&'static str; 1] = ["CAPTION"]; +pub(crate) const DEFAULT_ORG_ELEMENT_PARSED_KEYWORDS: [&str; 1] = ["CAPTION"]; -pub(crate) const DEFAULT_ORG_ELEMENT_DUAL_KEYWORDS: [&'static str; 2] = ["CAPTION", "RESULTS"]; +pub(crate) const DEFAULT_ORG_ELEMENT_DUAL_KEYWORDS: [&str; 2] = ["CAPTION", "RESULTS"]; -pub(crate) const DEFAULT_ORG_ELEMENT_AFFILIATED_KEYWORDS: [&'static str; 13] = [ +pub(crate) const DEFAULT_ORG_ELEMENT_AFFILIATED_KEYWORDS: [&str; 13] = [ "CAPTION", "DATA", "HEADER", "HEADERS", "LABEL", "NAME", "PLOT", "RESNAME", "RESULT", "RESULTS", "SOURCE", "SRCNAME", "TBLNAME", ]; -pub(crate) const DEFAULT_ORG_ELEMENT_KEYWORD_TRANSLATION_ALIST: [(&'static str, &'static str); 8] = [ +pub(crate) const DEFAULT_ORG_ELEMENT_KEYWORD_TRANSLATION_ALIST: [(&str, &str); 8] = [ ("DATA", "NAME"), ("LABEL", "NAME"), ("RESNAME", "NAME"), @@ -20,7 +20,7 @@ pub(crate) const DEFAULT_ORG_ELEMENT_KEYWORD_TRANSLATION_ALIST: [(&'static str, ("HEADERS", "HEADER"), ]; -pub(crate) const DEFAULT_ORG_LINK_PARAMETERS: [&'static str; 23] = [ +pub(crate) const DEFAULT_ORG_LINK_PARAMETERS: [&str; 23] = [ "id", "eww", "rmail", diff --git a/src/types/element.rs b/src/types/element.rs index d9f20e53..ab5d6554 100644 --- a/src/types/element.rs +++ b/src/types/element.rs @@ -26,6 +26,7 @@ use super::SetSource; use super::SpecialBlock; use super::StandardProperties; +#[allow(clippy::large_enum_variant)] #[derive(Debug)] pub enum Element<'s> { Paragraph(Paragraph<'s>), diff --git a/src/types/lesser_element.rs b/src/types/lesser_element.rs index a005e84d..83badc56 100644 --- a/src/types/lesser_element.rs +++ b/src/types/lesser_element.rs @@ -170,12 +170,10 @@ impl<'s> Paragraph<'s> { /// /// This is used for elements that support an "empty" content like greater blocks. pub(crate) fn of_text(input: &'s str) -> Self { - let mut objects = Vec::with_capacity(1); - objects.push(Object::PlainText(PlainText { source: input })); Paragraph { source: input, affiliated_keywords: AffiliatedKeywords::default(), - children: objects, + children: vec![Object::PlainText(PlainText { source: input })], } } } diff --git a/src/types/object.rs b/src/types/object.rs index 5d2f1ddb..870a1dfb 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -263,6 +263,7 @@ pub struct Superscript<'s> { pub children: Vec>, } +// TODO: Perhaps there is an optimization of converting to unix time we can do to shrink this struct. (ref: clippy::large_enum_variant on Element) #[derive(Debug, PartialEq, Clone)] pub struct Timestamp<'s> { pub source: &'s str, @@ -315,7 +316,7 @@ pub struct Minute(MinuteInner); impl Year { // TODO: Make a real error type instead of a boxed any error. - pub fn new<'s>(source: &'s str) -> Result> { + pub fn new(source: &str) -> Result> { let year = source.parse::()?; Ok(Year(year)) } @@ -327,9 +328,9 @@ impl Year { impl Month { // TODO: Make a real error type instead of a boxed any error. - pub fn new<'s>(source: &'s str) -> Result> { + pub fn new(source: &str) -> Result> { let month = source.parse::()?; - if month < 1 || month > 12 { + if !(1..=12).contains(&month) { Err("Month exceeds possible range.")?; } Ok(Month(month)) @@ -342,9 +343,9 @@ impl Month { impl DayOfMonth { // TODO: Make a real error type instead of a boxed any error. - pub fn new<'s>(source: &'s str) -> Result> { + pub fn new(source: &str) -> Result> { let day_of_month = source.parse::()?; - if day_of_month < 1 || day_of_month > 31 { + if !(1..=31).contains(&day_of_month) { Err("Day of month exceeds possible range.")?; } Ok(DayOfMonth(day_of_month)) @@ -357,7 +358,7 @@ impl DayOfMonth { impl Hour { // TODO: Make a real error type instead of a boxed any error. - pub fn new<'s>(source: &'s str) -> Result> { + pub fn new(source: &str) -> Result> { let hour = source.parse::()?; if hour > 23 { Err("Hour exceeds possible range.")?; @@ -372,7 +373,7 @@ impl Hour { impl Minute { // TODO: Make a real error type instead of a boxed any error. - pub fn new<'s>(source: &'s str) -> Result> { + pub fn new(source: &str) -> Result> { let minute = source.parse::()?; if minute > 59 { Err("Minute exceeds possible range.")?; @@ -731,21 +732,21 @@ impl<'s> RegularLink<'s> { /// Coalesce whitespace if the raw_link contains line breaks. /// /// This corresponds to the output you would get from the upstream emacs org-mode AST. - pub fn get_raw_link<'b>(&'b self) -> Cow<'b, str> { + pub fn get_raw_link(&self) -> Cow<'_, str> { coalesce_whitespace_if_line_break(&self.raw_link) } /// Coalesce whitespace if the path contains line breaks. /// /// This corresponds to the output you would get from the upstream emacs org-mode AST. - pub fn get_path<'b>(&'b self) -> Cow<'b, str> { + pub fn get_path(&self) -> Cow<'_, str> { coalesce_whitespace_if_line_break(&self.path) } /// Coalesce whitespace if the search_option contains line breaks. /// /// This corresponds to the output you would get from the upstream emacs org-mode AST. - pub fn get_search_option<'b>(&'b self) -> Option> { + pub fn get_search_option(&self) -> Option> { self.search_option .as_ref() .map(|search_option| coalesce_whitespace_if_line_break(search_option.borrow())) @@ -782,7 +783,7 @@ impl<'s> OrgMacro<'s> { pub fn get_args<'b>(&'b self) -> impl Iterator> + 'b { self.args .iter() - .map(|arg| coalesce_whitespace_escaped('\\', |c| ",".contains(c))(*arg)) + .map(|arg| coalesce_whitespace_escaped('\\', |c| ",".contains(c))(arg)) } }