Skip to content

Instantly share code, notes, and snippets.

@joepie91

joepie91/1.txt Secret

Last active October 19, 2018 04:03
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/0862349b2e3c2c0e63c07fb9668d9bed to your computer and use it in GitHub Desktop.
Save joepie91/0862349b2e3c2c0e63c07fb9668d9bed to your computer and use it in GitHub Desktop.
error[E0308]: mismatched types
--> src/protocols/irc/types.rs:156:16
|
156 | return &self.users;
| ^^^^^^^^^^^ expected trait types::user::User, found struct `protocols::irc::types::IRCUser`
|
= note: expected type `&std::vec::Vec<&dyn types::user::User>`
found type `&std::vec::Vec<&'a protocols::irc::types::IRCUser<'a>>`
use crate::types::User;
pub trait Room {
fn name(&self) -> String;
fn display_name(&self) -> String;
fn topic(&self) -> Option<String>;
fn identifier(&self) -> String;
fn users(&self) -> &Vec<&User>;
}
// ...
pub struct IRCChannel<'a> {
network: &'a IRCNetwork<'a>,
name: String,
topic: Option<String>,
users: Vec<&'a IRCUser<'a>>
}
// ...
impl<'a> Room for IRCChannel<'a> {
fn name(&self) -> String {
return self.name;
}
fn display_name(&self) -> String {
return self.name;
}
fn topic(&self) -> Option<String> {
return self.topic;
}
fn identifier(&self) -> String {
return format!("channel:{}@{}", self.name(), self.network.identifier());
}
fn users(&self) -> &Vec<&User> {
return &self.users;
}
}
// ...
impl<'a> User for IRCUser<'a> {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment