Renamed getter functions to not include get as is common practice.
This commit is contained in:
parent
b6ce088693
commit
20338f881f
3 changed files with 12 additions and 12 deletions
|
@ -86,7 +86,7 @@ impl Config {
|
|||
|
||||
/// Gets the alternate nicknames specified in the configuration.
|
||||
/// This defaults to an empty vector when not specified.
|
||||
pub fn get_alternate_nicknames(&self) -> Vec<&str> {
|
||||
pub fn alternate_nicknames(&self) -> Vec<&str> {
|
||||
self.alt_nicks.as_ref().map(|v| v.iter().map(|s| &s[..]).collect()).unwrap_or(vec![])
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ impl Message {
|
|||
}
|
||||
|
||||
/// Gets the nickname of the message source, if it exists.
|
||||
pub fn get_source_nickname(&self) -> Option<&str> {
|
||||
pub fn source_nickname(&self) -> Option<&str> {
|
||||
self.prefix.as_ref().and_then(|s|
|
||||
match (s.find('!'), s.find('@'), s.find('.')) {
|
||||
(_, _, Some(_)) => None,
|
||||
|
@ -137,22 +137,22 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn get_source_nickname() {
|
||||
fn source_nickname() {
|
||||
assert_eq!(Message::new(
|
||||
None, "PING", vec![], Some("data")
|
||||
).unwrap().get_source_nickname(), None);
|
||||
).unwrap().source_nickname(), None);
|
||||
assert_eq!(Message::new(
|
||||
Some("irc.test.net"), "PING", vec![], Some("data")
|
||||
).unwrap().get_source_nickname(), None);
|
||||
).unwrap().source_nickname(), None);
|
||||
assert_eq!(Message::new(
|
||||
Some("test!test@test"), "PING", vec![], Some("data")
|
||||
).unwrap().get_source_nickname(), Some("test"));
|
||||
).unwrap().source_nickname(), Some("test"));
|
||||
assert_eq!(Message::new(
|
||||
Some("test@test"), "PING", vec![], Some("data")
|
||||
).unwrap().get_source_nickname(), Some("test"));
|
||||
).unwrap().source_nickname(), Some("test"));
|
||||
assert_eq!(Message::new(
|
||||
Some("test"), "PING", vec![], Some("data")
|
||||
).unwrap().get_source_nickname(), Some("test"));
|
||||
).unwrap().source_nickname(), Some("test"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -289,14 +289,14 @@ impl<T: IrcRead, U: IrcWrite> IrcServer<T, U> where Connection<T, U>: Reconnect
|
|||
PING(ref data, _) => try!(self.send_pong(&data)),
|
||||
JOIN(ref chan, _, _) => if cfg!(not(feature = "nochanlists")) {
|
||||
if let Some(vec) = self.chanlists().lock().unwrap().get_mut(&chan.to_owned()) {
|
||||
if let Some(src) = msg.get_source_nickname() {
|
||||
if let Some(src) = msg.source_nickname() {
|
||||
vec.push(User::new(src))
|
||||
}
|
||||
}
|
||||
},
|
||||
PART(ref chan, _) => if cfg!(not(feature = "nochanlists")) {
|
||||
if let Some(vec) = self.chanlists().lock().unwrap().get_mut(&chan.to_owned()) {
|
||||
if let Some(src) = msg.get_source_nickname() {
|
||||
if let Some(src) = msg.source_nickname() {
|
||||
if let Some(n) = vec.iter().position(|x| x.get_nickname() == src) {
|
||||
vec.swap_remove(n);
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ impl<T: IrcRead, U: IrcWrite> IrcServer<T, U> where Connection<T, U>: Reconnect
|
|||
};
|
||||
if target.starts_with("#") {
|
||||
try!(self.handle_ctcp(&target, tokens))
|
||||
} else if let Some(user) = msg.get_source_nickname() {
|
||||
} else if let Some(user) = msg.source_nickname() {
|
||||
try!(self.handle_ctcp(user, tokens))
|
||||
}
|
||||
},
|
||||
|
@ -355,7 +355,7 @@ impl<T: IrcRead, U: IrcWrite> IrcServer<T, U> where Connection<T, U>: Reconnect
|
|||
},
|
||||
Command::Response(Response::ERR_NICKNAMEINUSE, _, _) |
|
||||
Command::Response(Response::ERR_ERRONEOUSNICKNAME, _, _) => {
|
||||
let alt_nicks = self.config().get_alternate_nicknames();
|
||||
let alt_nicks = self.config().alternate_nicknames();
|
||||
let mut index = self.state.alt_nick_index.write().unwrap();
|
||||
if *index >= alt_nicks.len() {
|
||||
panic!("All specified nicknames were in use.")
|
||||
|
|
Loading…
Add table
Reference in a new issue