Skip to content

Commit 575767d

Browse files
committed
NameString: slight modernization
Changes: * Remove operator_less() * Rename get_name() -> to_godot_string() * Documentation
1 parent a4409a9 commit 575767d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

gdnative-core/src/core_types/string.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,12 @@ impl fmt::Debug for Utf8String {
542542
}
543543
}
544544

545+
/// Interned string.
546+
///
547+
/// Like [`GodotString`], but unique: two `StringName`s with the same string value share the same
548+
/// internal object. Just like the `GodotString` struct, this type is immutable.
549+
///
550+
/// Use [`Self::from_godot_string()`] and [`Self::to_godot_string()`] for conversions.
545551
pub struct StringName(pub(crate) sys::godot_string_name);
546552

547553
impl StringName {
@@ -579,15 +585,10 @@ impl StringName {
579585
}
580586

581587
#[inline]
582-
pub fn get_name(&self) -> GodotString {
588+
pub fn to_godot_string(&self) -> GodotString {
583589
unsafe { GodotString((get_api().godot_string_name_get_name)(&self.0)) }
584590
}
585591

586-
#[inline]
587-
pub fn operator_less(&self, s: &StringName) -> bool {
588-
unsafe { (get_api().godot_string_name_operator_less)(&self.0, &s.0) }
589-
}
590-
591592
#[doc(hidden)]
592593
#[inline]
593594
pub fn sys(&self) -> *const sys::godot_string_name {
@@ -617,7 +618,7 @@ impl_basic_traits_as_sys! {
617618
impl fmt::Debug for StringName {
618619
#[inline]
619620
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
620-
self.get_name().to_string().fmt(f)
621+
self.to_godot_string().fmt(f)
621622
}
622623
}
623624

0 commit comments

Comments
 (0)