SUPERMAX on Nostr: The apostrophe needed in the syntax is confusing to me (...<'a>...) You can also ...
The apostrophe needed in the syntax is confusing to me (...<'a>...)
You can also share buffers by having the two "Chars" point to the same buffer, like so below
-----
struct Chars<'a> {
data: &'a str,
}
fn process_chars<'a>(chars1: Chars<'a>, chars2: Chars<'a>) {
// Both chars1 and chars2 point to the same buffer
println!("Processing: {} and {}", chars1.data, chars2.data);
}
-----
I'm really not good at any of this so please take this with less than two sats of my own worth here. Trying to help both yourself & my own C/C++ to Rust journey 💜
I was also told to pay better attention to the borrow checker's messages too
You can also share buffers by having the two "Chars" point to the same buffer, like so below
-----
struct Chars<'a> {
data: &'a str,
}
fn process_chars<'a>(chars1: Chars<'a>, chars2: Chars<'a>) {
// Both chars1 and chars2 point to the same buffer
println!("Processing: {} and {}", chars1.data, chars2.data);
}
-----
I'm really not good at any of this so please take this with less than two sats of my own worth here. Trying to help both yourself & my own C/C++ to Rust journey 💜
I was also told to pay better attention to the borrow checker's messages too