Skip to content

Instantly share code, notes, and snippets.

@joepie91

joepie91/1.txt Secret

Last active October 19, 2018 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joepie91/62d658dab9c782afe0f2027c08208ed6 to your computer and use it in GitHub Desktop.
Save joepie91/62d658dab9c782afe0f2027c08208ed6 to your computer and use it in GitHub Desktop.
error[E0308]: mismatched types
--> src/protocols/irc/types.rs:156:16
|
156 | return &self.users
| ________________^
157 | | .into_iter()
158 | | .map(|x| {
159 | | return x as &dyn User;
160 | | })
161 | | .collect();
| |______________________^ expected struct `std::vec::Vec`, found reference
|
= note: expected type `std::vec::Vec<&dyn types::user::User>`
found type `&_`
warning: trivial cast: `&protocols::irc::types::IRCUser<'_>` as `&dyn types::user::User`
--> src/protocols/irc/types.rs:159:24
|
159 | return x as &dyn User;
| ^^^^^^^^^^^^^^
|
note: lint level defined here
--> src/main.rs:3:9
|
3 | #![warn(trivial_casts)]
| ^^^^^^^^^^^^^
= help: cast can be replaced by coercion; this might require a temporary variable
use crate::types::User;
pub trait Room<'a> {
fn name(&self) -> String;
fn display_name(&self) -> String;
fn topic(&self) -> Option<String>;
fn identifier(&self) -> String;
fn users(&self) -> Vec<&dyn User>;
/* FIXME: Icon/avatar? */
}
// ...
impl<'a> Room<'a> for IRCChannel<'a> {
// ...
fn users(&self) -> Vec<&dyn User> {
return &self.users
.into_iter()
.map(|x| {
return x as &dyn User;
})
.collect();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment