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
Published at
2024-12-27 02:30:22Event JSON
{
"id": "875d01b17ee782f5886a015d755c8b60d9a4d40fa8a411c724faf812a6b99fed",
"pubkey": "ae1008d23930b776c18092f6eab41e4b09fcf3f03f3641b1b4e6ee3aa166d760",
"created_at": 1735266622,
"kind": 1,
"tags": [
[
"e",
"ef043405a80f1be80e0c27707b8d3d356312b61b831ec689207a0cdd78b0f2da",
"",
"root"
],
[
"e",
"2935a05c436f903d33dd9049e924327f5c38c4d11a08ab6c56f6b03e7ab467ce",
"",
"reply"
],
[
"p",
"ae1008d23930b776c18092f6eab41e4b09fcf3f03f3641b1b4e6ee3aa166d760"
],
[
"p",
"3ad806433f1d09d2643dd8bf4162890270449539839aab7b9da215e1d5681bac"
],
[
"r",
"chars1.data"
],
[
"r",
"chars2.data"
]
],
"content": "The apostrophe needed in the syntax is confusing to me (...\u003c'a\u003e...)\n\nYou can also share buffers by having the two \"Chars\" point to the same buffer, like so below\n\n\n-----\nstruct Chars\u003c'a\u003e {\n data: \u0026'a str,\n}\nfn process_chars\u003c'a\u003e(chars1: Chars\u003c'a\u003e, chars2: Chars\u003c'a\u003e) {\n // Both chars1 and chars2 point to the same buffer\n println!(\"Processing: {} and {}\", chars1.data, chars2.data);\n}\n-----\n\n\nI'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 \u0026 my own C/C++ to Rust journey 💜\n\nI was also told to pay better attention to the borrow checker's messages too",
"sig": "04b817b5e95b34230fad765fda545350f576db0b98734470f3df75361d9a70fc127930a2a52c6a524b2eb6589c9b2ab312887f805dd72c7613fc1eeaa741385b"
}