Switch to using AsRef<str> to make compare_property_quoted_string generic.
This commit is contained in:
parent
89fcf6cb54
commit
4716e1ce5b
@ -56,7 +56,14 @@ pub(crate) fn compare_property_always_nil<'b, 's, 'x, R, RG>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn compare_property_quoted_string<'b, 's, 'x, R, RG: Fn(R) -> Option<&'s str>>(
|
pub(crate) fn compare_property_quoted_string<
|
||||||
|
'b,
|
||||||
|
's,
|
||||||
|
'x,
|
||||||
|
R,
|
||||||
|
RV: AsRef<str> + std::fmt::Debug,
|
||||||
|
RG: Fn(R) -> Option<RV>,
|
||||||
|
>(
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust_node: R,
|
rust_node: R,
|
||||||
emacs_field: &'x str,
|
emacs_field: &'x str,
|
||||||
@ -64,27 +71,7 @@ pub(crate) fn compare_property_quoted_string<'b, 's, 'x, R, RG: Fn(R) -> Option<
|
|||||||
) -> Result<Option<(DiffStatus, Option<String>)>, Box<dyn std::error::Error>> {
|
) -> Result<Option<(DiffStatus, Option<String>)>, Box<dyn std::error::Error>> {
|
||||||
let value = get_property_quoted_string(emacs, emacs_field)?;
|
let value = get_property_quoted_string(emacs, emacs_field)?;
|
||||||
let rust_value = rust_value_getter(rust_node);
|
let rust_value = rust_value_getter(rust_node);
|
||||||
if rust_value != value.as_ref().map(String::as_str) {
|
if rust_value.as_ref().map(|s| s.as_ref()) != value.as_ref().map(String::as_str) {
|
||||||
let this_status = DiffStatus::Bad;
|
|
||||||
let message = Some(format!(
|
|
||||||
"{} mismatch (emacs != rust) {:?} != {:?}",
|
|
||||||
emacs_field, value, rust_value
|
|
||||||
));
|
|
||||||
Ok(Some((this_status, message)))
|
|
||||||
} else {
|
|
||||||
Ok(None)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn compare_property_quoted_string_owned<'b, 's, 'x, R, RG: Fn(R) -> Option<String>>(
|
|
||||||
emacs: &'b Token<'s>,
|
|
||||||
rust_node: R,
|
|
||||||
emacs_field: &'x str,
|
|
||||||
rust_value_getter: RG,
|
|
||||||
) -> Result<Option<(DiffStatus, Option<String>)>, Box<dyn std::error::Error>> {
|
|
||||||
let value = get_property_quoted_string(emacs, emacs_field)?;
|
|
||||||
let rust_value = rust_value_getter(rust_node);
|
|
||||||
if rust_value != value {
|
|
||||||
let this_status = DiffStatus::Bad;
|
let this_status = DiffStatus::Bad;
|
||||||
let message = Some(format!(
|
let message = Some(format!(
|
||||||
"{} mismatch (emacs != rust) {:?} != {:?}",
|
"{} mismatch (emacs != rust) {:?} != {:?}",
|
||||||
|
@ -6,7 +6,6 @@ use std::collections::HashSet;
|
|||||||
use super::compare_field::compare_identity;
|
use super::compare_field::compare_identity;
|
||||||
use super::compare_field::compare_property_always_nil;
|
use super::compare_field::compare_property_always_nil;
|
||||||
use super::compare_field::compare_property_quoted_string;
|
use super::compare_field::compare_property_quoted_string;
|
||||||
use super::compare_field::compare_property_quoted_string_owned;
|
|
||||||
use super::compare_field::compare_property_unquoted_atom;
|
use super::compare_field::compare_property_unquoted_atom;
|
||||||
use super::elisp_fact::ElispFact;
|
use super::elisp_fact::ElispFact;
|
||||||
use super::elisp_fact::GetElispFact;
|
use super::elisp_fact::GetElispFact;
|
||||||
@ -2786,7 +2785,7 @@ fn compare_regular_link<'b, 's>(
|
|||||||
(
|
(
|
||||||
EmacsField::Required(":path"),
|
EmacsField::Required(":path"),
|
||||||
|r| Some(r.get_path()),
|
|r| Some(r.get_path()),
|
||||||
compare_property_quoted_string_owned
|
compare_property_quoted_string
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
EmacsField::Required(":format"),
|
EmacsField::Required(":format"),
|
||||||
@ -2796,7 +2795,7 @@ fn compare_regular_link<'b, 's>(
|
|||||||
(
|
(
|
||||||
EmacsField::Required(":raw-link"),
|
EmacsField::Required(":raw-link"),
|
||||||
|r| Some(r.get_raw_link()),
|
|r| Some(r.get_raw_link()),
|
||||||
compare_property_quoted_string_owned
|
compare_property_quoted_string
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
EmacsField::Required(":application"),
|
EmacsField::Required(":application"),
|
||||||
@ -2806,7 +2805,7 @@ fn compare_regular_link<'b, 's>(
|
|||||||
(
|
(
|
||||||
EmacsField::Required(":search-option"),
|
EmacsField::Required(":search-option"),
|
||||||
|r| r.get_search_option(),
|
|r| r.get_search_option(),
|
||||||
compare_property_quoted_string_owned
|
compare_property_quoted_string
|
||||||
)
|
)
|
||||||
)? {
|
)? {
|
||||||
this_status = new_status;
|
this_status = new_status;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user