-
-
Save joepie91/62d658dab9c782afe0f2027c08208ed6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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