I am experimenting rust by implementing a simple game, and quickly ran into a situation where I find it is hard to decide what is a better approach an ...
I am experimenting rust by implementing a simple game, and quickly ran into a situation where I find it is hard to decide what is a better approach an ...
I'm trying to do some parallel processing on a list of values: fn process_list(list: Vec<f32>) -> Vec<f32> { // Block F let chunk_ ...
Here is the code: struct A<'a, 'b> { s1: &'a str, s2: &'b str, } struct B<'a> { s3: &'a str, } macro_rules! gen ...
Noticed the following difference between match and if in Rust regarding lifetimes - let's say we have simple struct: struct Foo; impl Foo { is_val ...
Consider the following code: So GetTemp() returns a temporary object, which then gets assigned to a constant reference variable. However, that cons ...
I have this code: I need the dispatcher field in the structure, but when specifying the field type, I also need to specify the lifetime. This is no ...
I have a trait Atom that has many associated types, of which one is an owned version OP and the other is a borrow version O of essentially the same da ...
The following code can work when I use a custom trait. But I don't understand why it fails when trying to use the builtin "From" trait. Error: ...
I want to create a wrapper around (nested) slices for easy operations on multidimensional data, owned by a different struct. The most basic version of ...
I am designing code that should be generic over a trait Atom, that contains many associated types that logically belong together. In the simplified ex ...
I'm trying to write a function that takes a generic argument over a trait with a GAT. Here is my code (playground): struct Owned; struct Ref<'a& ...
Consider the following Rust code: use std::thread; fn main() { bar(); loop {} } fn bar() { let var = b"foo"; thread::spawn(|| { ...
Can anyone suggest what I'm doing wrong. I'm writing a Callback structure for indirectly calling a closure, this code will be used with a C library. ...
I am trying to make an iterator out of some struct, s1, that has references within it with some lifetimes, say 'a and 'b. The iterator elements are ne ...
In the following code i get the error Lifetime 'a already in scope for the new method. What is the issue in using the same scope as A? I thought it ma ...
I want to write a FuncWrapper struct with a new function that takes a (Boxed) closure as parameter, and returns a decorated closure that just adds som ...
In trying to compile the code The compiler gives I have been reading through similar questions Parameter type may not live long enough? and The ...
I am using crate clap v4。When I try to write something validating arguments against regex, I had some problem with lifetimes. Document of ValuePar ...
I'm trying to use RustyBuzz to do some text display. Shaping is done by a struct called Face<'a> which contains a reference to bytes from a font ...
There are about 50 questions on Stack Overflow about "borrowed value does not live long enough", but I haven't found one that answers this question. H ...