Assume :standard-properties is an expected field.
This commit is contained in:
27
src/compare/compare_field.rs
Normal file
27
src/compare/compare_field.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use super::diff::DiffStatus;
|
||||
use super::sexp::Token;
|
||||
use super::util::get_property_quoted_string;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum EmacsField<'s> {
|
||||
Required(&'s str),
|
||||
Optional(&'s str),
|
||||
}
|
||||
|
||||
pub(crate) fn compare_property_quoted_string_required_value<'b, 's, 'x>(
|
||||
emacs: &'b Token<'s>,
|
||||
emacs_field: &'x str,
|
||||
rust_value: &'s str,
|
||||
) -> Result<Option<(DiffStatus, Option<String>)>, Box<dyn std::error::Error>> {
|
||||
let value = get_property_quoted_string(emacs, emacs_field)?;
|
||||
if value.as_ref().map(String::as_str) != Some(rust_value) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user