Cleanup.
This commit is contained in:
@@ -1,16 +1,34 @@
|
||||
macro_rules! compare_noop {
|
||||
($($field:expr),+) => {
|
||||
$(
|
||||
EmacsField::Required(":foo"),
|
||||
compare_identity,
|
||||
impl_compare_noop
|
||||
),+
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) use compare_noop;
|
||||
|
||||
/// Create iterators for ast nodes where it only has to iterate over children
|
||||
/// Assert only the listed properties exist on the Emacs AST node and compare their values to the values on the rust AST node.
|
||||
///
|
||||
/// Example invocation:
|
||||
/// ```
|
||||
/// if let Some((new_status, new_message)) = compare_properties!(
|
||||
/// emacs,
|
||||
/// rust,
|
||||
/// (
|
||||
/// EmacsField::Required(":key"),
|
||||
/// |r| Some(r.key),
|
||||
/// compare_property_quoted_string
|
||||
/// ),
|
||||
/// (
|
||||
/// EmacsField::Required(":value"),
|
||||
/// |r| Some(r.contents),
|
||||
/// compare_property_quoted_string
|
||||
/// ),
|
||||
/// (EmacsField::Required(":pre-blank"), compare_identity, compare_noop)
|
||||
/// )? {
|
||||
/// this_status = new_status;
|
||||
/// message = new_message;
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Or if the node has no properties aside from :standard-properties, we can still assert that the node has no unexpected properties:
|
||||
/// ```
|
||||
/// if let Some((new_status, new_message)) = compare_properties!(emacs)? {
|
||||
/// this_status = new_status;
|
||||
/// message = new_message;
|
||||
/// }
|
||||
/// ```
|
||||
macro_rules! compare_properties {
|
||||
($emacs:expr, $rust:expr, $(($emacs_field:expr, $rust_value_getter:expr, $compare_fn: expr)),+) => {
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user