Trait GodotStringExt
pub trait GodotStringExt {
// Required methods
fn to_gstring(&self) -> GString;
fn to_string_name(&self) -> StringName;
fn to_node_path(&self) -> NodePath;
}Expand description
Extension trait for converting to Godot string types.
Provides types like &str and String with “extension functions” to convert to one of the Godot string types.
An explicitly named val.to_gstring() method has several advantages over the From trait (which may be phased out over time):
- Compared to
GString::from(&val), it is shorter and can be used in fluent expressions such asval.replace(...).to_gstring(). - Compared to
val.into(), it makes the conversion more explicit by naming the type, and never runs into type-inference problems (theinto()function requires an explicit type declaration somewhere).
Required Methods§
fn to_gstring(&self) -> GString
fn to_gstring(&self) -> GString
Convert to a GString.
fn to_string_name(&self) -> StringName
fn to_string_name(&self) -> StringName
Convert to a StringName.
fn to_node_path(&self) -> NodePath
fn to_node_path(&self) -> NodePath
Convert to a NodePath.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".