Skip to content

Commit a9a4814

Browse files
committed
Use StdString for consistency in chunk.rs
1 parent b1f73ec commit a9a4814

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/chunk.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub enum CompileConstant {
160160
Boolean(bool),
161161
Number(crate::Number),
162162
Vector(crate::Vector),
163-
String(String),
163+
String(StdString),
164164
}
165165

166166
#[cfg(any(feature = "luau", doc))]
@@ -192,7 +192,7 @@ impl From<&str> for CompileConstant {
192192
}
193193

194194
#[cfg(any(feature = "luau", doc))]
195-
type LibraryMemberConstantMap = HashMap<(String, String), CompileConstant>;
195+
type LibraryMemberConstantMap = HashMap<(StdString, StdString), CompileConstant>;
196196

197197
/// Luau compiler
198198
#[cfg(any(feature = "luau", doc))]
@@ -203,14 +203,14 @@ pub struct Compiler {
203203
debug_level: u8,
204204
type_info_level: u8,
205205
coverage_level: u8,
206-
vector_lib: Option<String>,
207-
vector_ctor: Option<String>,
208-
vector_type: Option<String>,
209-
mutable_globals: Vec<String>,
210-
userdata_types: Vec<String>,
211-
libraries_with_known_members: Vec<String>,
206+
vector_lib: Option<StdString>,
207+
vector_ctor: Option<StdString>,
208+
vector_type: Option<StdString>,
209+
mutable_globals: Vec<StdString>,
210+
userdata_types: Vec<StdString>,
211+
libraries_with_known_members: Vec<StdString>,
212212
library_constants: Option<LibraryMemberConstantMap>,
213-
disabled_builtins: Vec<String>,
213+
disabled_builtins: Vec<StdString>,
214214
}
215215

216216
#[cfg(any(feature = "luau", doc))]
@@ -290,21 +290,21 @@ impl Compiler {
290290

291291
#[doc(hidden)]
292292
#[must_use]
293-
pub fn set_vector_lib(mut self, lib: impl Into<String>) -> Self {
293+
pub fn set_vector_lib(mut self, lib: impl Into<StdString>) -> Self {
294294
self.vector_lib = Some(lib.into());
295295
self
296296
}
297297

298298
#[doc(hidden)]
299299
#[must_use]
300-
pub fn set_vector_ctor(mut self, ctor: impl Into<String>) -> Self {
300+
pub fn set_vector_ctor(mut self, ctor: impl Into<StdString>) -> Self {
301301
self.vector_ctor = Some(ctor.into());
302302
self
303303
}
304304

305305
#[doc(hidden)]
306306
#[must_use]
307-
pub fn set_vector_type(mut self, r#type: impl Into<String>) -> Self {
307+
pub fn set_vector_type(mut self, r#type: impl Into<StdString>) -> Self {
308308
self.vector_type = Some(r#type.into());
309309
self
310310
}
@@ -484,7 +484,7 @@ impl Compiler {
484484
if bytecode.first() == Some(&0) {
485485
// The rest of the bytecode is the error message starting with `:`
486486
// See https://github.com/luau-lang/luau/blob/0.640/Compiler/src/Compiler.cpp#L4336
487-
let message = String::from_utf8_lossy(&bytecode[2..]).to_string();
487+
let message = StdString::from_utf8_lossy(&bytecode[2..]).into_owned();
488488
return Err(Error::SyntaxError {
489489
incomplete_input: message.ends_with("<eof>"),
490490
message,
@@ -507,7 +507,7 @@ impl Chunk<'_> {
507507
/// - `@` - file path (when truncation is needed, the end of the file path is kept, as this is
508508
/// more useful for identifying the file)
509509
/// - `=` - custom chunk name (when truncation is needed, the beginning of the name is kept)
510-
pub fn set_name(mut self, name: impl Into<String>) -> Self {
510+
pub fn set_name(mut self, name: impl Into<StdString>) -> Self {
511511
self.name = name.into();
512512
self
513513
}
@@ -755,7 +755,7 @@ impl Chunk<'_> {
755755
ChunkMode::Text
756756
}
757757

758-
fn convert_name(name: String) -> Result<CString> {
758+
fn convert_name(name: StdString) -> Result<CString> {
759759
CString::new(name).map_err(|err| Error::runtime(format!("invalid name: {err}")))
760760
}
761761

0 commit comments

Comments
 (0)