Addition:
When I was trying adding more functions (not the len and byte function in this PR), I have encountered some issues about lifetime when using String::new, possibly due to my limitation of Rust knowledge.
[0] % cargo check
Checking luster v0.1.0 (/mnt/working/Programming/Rust/luster)
error[E0477]: the type `[closure@src/stdlib/string.rs:12:41: 26:14 mc:&gc_arena::context::MutationContext<'gc, '_>]` does not fulfill the required lifetime--> src/stdlib/string.rs:12:13
|12| Callback::new_immediate(mc, |args| {
| ^^^^^^^^^^^^^^^^^^^^^^^|= note: type must satisfy the static lifetime
error[E0621]: explicit lifetime required in the type of `mc`--> src/stdlib/string.rs:12:13
|5| pub fn load_string<'gc>(mc: MutationContext<'gc, '_>, _: Root<'gc>, env: Table<'gc>) {
| ------------------------help: add explicit lifetime `'static` to the type of `mc`: `gc_arena::context::MutationContext<'gc, 'static>`...12| Callback::new_immediate(mc, |args| {
| ^^^^^^^^^^^^^^^^^^^^^^^lifetime `'static` requirederror: aborting due to 2 previous errorsSome errors occurred: E0477, E0621.For more information about an error, try `rustc --explain E0477`.error: Could not compile `luster`.
To learn more, run the command again with --verbose.
I have only added two functions --
len
andbyte
.Addition: When I was trying adding more functions (not the
len
andbyte
function in this PR), I have encountered some issues about lifetime when usingString::new
, possibly due to my limitation of Rust knowledge.