Merge pull request #123 from isra17/develop
Fix wrong RPL numeric formatting
This commit is contained in:
commit
e7e1149bee
1 changed files with 19 additions and 10 deletions
|
@ -421,18 +421,14 @@ impl<'a> From<&'a Command> for String {
|
||||||
Command::CHGHOST(ref u, ref h) => stringify("CHGHOST", &[u, h], None),
|
Command::CHGHOST(ref u, ref h) => stringify("CHGHOST", &[u, h], None),
|
||||||
|
|
||||||
Command::Response(ref resp, ref a, Some(ref s)) => {
|
Command::Response(ref resp, ref a, Some(ref s)) => {
|
||||||
stringify(
|
stringify(&format!("{:03}", *resp as u16),
|
||||||
&format!("{}", *resp as u16),
|
&a.iter().map(|s| &s[..]).collect::<Vec<_>>(),
|
||||||
&a.iter().map(|s| &s[..]).collect::<Vec<_>>(),
|
Some(s))
|
||||||
Some(s),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Command::Response(ref resp, ref a, None) => {
|
Command::Response(ref resp, ref a, None) => {
|
||||||
stringify(
|
stringify(&format!("{:03}", *resp as u16),
|
||||||
&format!("{}", *resp as u16),
|
&a.iter().map(|s| &s[..]).collect::<Vec<_>>(),
|
||||||
&a.iter().map(|s| &s[..]).collect::<Vec<_>>(),
|
None)
|
||||||
None,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Command::Raw(ref c, ref a, Some(ref s)) => {
|
Command::Raw(ref c, ref a, Some(ref s)) => {
|
||||||
stringify(c, &a.iter().map(|s| &s[..]).collect::<Vec<_>>(), Some(s))
|
stringify(c, &a.iter().map(|s| &s[..]).collect::<Vec<_>>(), Some(s))
|
||||||
|
@ -1763,3 +1759,16 @@ impl FromStr for BatchSubCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use super::Response;
|
||||||
|
use super::Command;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn format_response() {
|
||||||
|
assert!(String::from(&Command::Response(Response::RPL_WELCOME,
|
||||||
|
vec!["foo".into()],
|
||||||
|
None)) == "001 foo");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue