How to add multiple errors if Messages functions take self ? #6
Answered
by
maxcountryman
HosMercury
asked this question in
Q&A
-
the first time adding to messages will consume it ? right ? so what if I want to add multiple errors ? error[E0382]: use of moved value: `messages`
--> src/web/auth.rs:80:17
|
67 | messages: Messages,
| -------- move occurs because `messages` has type `axum_messages::Messages`, which does not implement the `Copy` trait
...
79 | messages.error("err 1");
| -------------- `messages` moved due to this method call
80 | messages.error("err2");
| ^^^^^^^^ value used here after move
``` |
Beta Was this translation helpful? Give feedback.
Answered by
maxcountryman
Feb 23, 2024
Replies: 1 comment 3 replies
-
The idea here is that you'll use a "fluent" API most of the time. So following along with the example, we do something like: messages.error("err 1").error("err 2"); |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Each method returns
self
, so you can rebind the variable if you aren't able to use the fluent API directly. For instance, we can modify the example like so: