python (65.1k questions)
javascript (44.2k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (12.9k questions)
Why is the move keyword needed when returning a closure which captures a Copy type?
godbolt
fn foo(c: char) -> impl Fn() -> i32 {
|| bar(c)
}
fn bar(_: char) -> i32 {
42
}
Which throws an error
error[E0597]: `c` does not live long enough
--> src/lib.rs:2:12
|...
skelix
Votes: 0
Answers: 2
How to solve "Returns a value referencing data owned by the current function" (Actual depenecies between structs)
I'm learning Rust (I'm a C++ dev) and I'm still getting used to the borrow checker.
I have the following example (which is also on godbolt: https://godbolt.org/z/z873x9cPn):
struct Foo {
value: i3...
Pau6b
Votes: 0
Answers: 1
How can I pass a value and a reference to it into a struct
I've been recently learning Rust while trying to make a Synthesia-like app (similar to a piano roll). While separating some of the code into its own module, I got into trouble trying to write a "...
Valazo
Votes: 0
Answers: 0
Rust: Why can't I move a value twice?
New to Rust, really feel like I'm missing something here.
In the below code, there are two nested closures which are important to the question: app.connect_activate and draw_area.connect_draw. I am tr...
Edward Peters
Votes: 0
Answers: 1