pub trait SemanticsSortKey: Debug + Any {
// Required methods
fn name(&self) -> Option<&str>;
fn do_compare(&self, other: &dyn SemanticsSortKey) -> Ordering;
}Expand description
Base class for all sort keys for SemanticsProperties::sort_key accessibility
traversal order sorting.
Sort keys are sorted by name, then by the comparison that the subclass
implements. If SemanticsProperties::sort_key is specified, sort keys within
the same semantic group must all be of the same type.
Keys with no name are compared to other keys with no
name, and will be traversed before those with a name.
If no sort key is applied to a semantics node, then it will be ordered using a platform dependent default algorithm.
Required Methods§
Sourcefn name(&self) -> Option<&str>
fn name(&self) -> Option<&str>
An optional name that will group this sort key with other sort keys of the
same name.
Sort keys must have the same type when compared.
Sourcefn do_compare(&self, other: &dyn SemanticsSortKey) -> Ordering
fn do_compare(&self, other: &dyn SemanticsSortKey) -> Ordering
The implementation of [compare_to](dyn SemanticsSortKey::compare_to).
The argument is guaranteed to be of the same type as this object and have
the same name.
The method should return Ordering::Less if this object comes earlier in
the sort order than the argument; and Ordering::Greater if it comes later
in the sort order. Returning Ordering::Equal causes the system to use default sort
order.
Implementations§
Source§impl dyn SemanticsSortKey
impl dyn SemanticsSortKey
Sourcepub fn compare_to(&self, other: &dyn SemanticsSortKey) -> Ordering
pub fn compare_to(&self, other: &dyn SemanticsSortKey) -> Ordering
Dart’s compareTo: by name first and then the subclass’s ordering.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".