From be6a0752556260006ce70d805c3889db820fa701 Mon Sep 17 00:00:00 2001 From: Mivort Date: Fri, 25 Oct 2024 18:24:10 +0100 Subject: [PATCH] Derive Ord and PartialOrd for ClassName type This PR adds two simple derives (Ord and PartialOrd) to allow the storage of ClassName type in ordered maps (BTreeSet/BTreeMap etc.). Co-authored-by: Jan Haller --- godot-core/src/meta/class_name.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/godot-core/src/meta/class_name.rs b/godot-core/src/meta/class_name.rs index a5318f1aa..ac122dbdb 100644 --- a/godot-core/src/meta/class_name.rs +++ b/godot-core/src/meta/class_name.rs @@ -96,7 +96,12 @@ impl ClassNameSource { /// This struct is very cheap to copy. The actual names are cached globally. /// /// If you need to create your own class name, use [`new_cached()`][Self::new_cached]. -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] +/// +/// # Ordering +/// +/// `ClassName`s are **not** ordered lexicographically, and the ordering relation is **not** stable across multiple runs of your +/// application. When lexicographical order is needed, it's possible to convert this type to [`GString`] or [`String`]. +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] pub struct ClassName { global_index: u16, }