1
- use std:: { marker:: PhantomData , ops:: { Deref , DerefMut } } ;
1
+ use std:: { fmt :: { Display , Formatter } , marker:: PhantomData , ops:: { Deref , DerefMut } , str :: FromStr } ;
2
2
3
- use crate :: prelude:: { Il2CppArray , Il2CppClass , Il2CppClassData , Il2CppObject , MethodInfo } ;
3
+ use crate :: prelude:: { Il2CppArray , Il2CppClass , Il2CppClassData , Il2CppObject , MethodInfo , OptionalMethod } ;
4
4
5
5
/// A type alias for `Il2CppObject<SystemString>`.
6
6
///
@@ -97,6 +97,24 @@ impl Il2CppString {
97
97
}
98
98
}
99
99
100
+ impl AsRef < [ u16 ] > for & ' _ Il2CppString {
101
+ fn as_ref ( & self ) -> & [ u16 ] {
102
+ unsafe { std:: slice:: from_raw_parts ( self . string . as_ptr ( ) , self . len as _ ) }
103
+ }
104
+ }
105
+
106
+ impl AsMut < [ u16 ] > for & ' _ mut Il2CppString {
107
+ fn as_mut ( & mut self ) -> & mut [ u16 ] {
108
+ unsafe { std:: slice:: from_raw_parts_mut ( self . string . as_mut_ptr ( ) , self . len as _ ) }
109
+ }
110
+ }
111
+
112
+ impl Display for Il2CppString {
113
+ fn fmt ( & self , f : & mut Formatter ) -> std:: fmt:: Result {
114
+ write ! ( f, "{}" , self . to_string( ) )
115
+ }
116
+ }
117
+
100
118
impl < T : AsRef < str > > From < T > for & ' _ Il2CppString {
101
119
fn from ( value : T ) -> Self {
102
120
Il2CppString :: new ( value)
@@ -105,7 +123,15 @@ impl<T: AsRef<str>> From<T> for &'_ Il2CppString {
105
123
106
124
impl PartialEq for Il2CppString {
107
125
fn eq ( & self , other : & Self ) -> bool {
108
- unsafe { system_string_equals ( self , other) }
126
+ unsafe { system_string_equals ( self , other, None ) }
127
+ }
128
+ }
129
+
130
+ impl FromStr for & ' _ Il2CppString {
131
+ type Err = ( ) ;
132
+
133
+ fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
134
+ Ok ( Il2CppString :: new ( s) )
109
135
}
110
136
}
111
137
0 commit comments