make say use Option
This commit is contained in:
parent
f01661339e
commit
32304f4ea0
1 changed files with 3 additions and 3 deletions
|
|
@ -1,16 +1,16 @@
|
|||
#[derive(Default)]
|
||||
pub struct SayCommand {
|
||||
message: String
|
||||
message: Option<String>
|
||||
}
|
||||
|
||||
impl SayCommand {
|
||||
pub fn message(mut self, msg: impl Into<String>) -> Self {
|
||||
self.message = msg.into();
|
||||
self.message = Some(msg.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn build(self) -> super::Command {
|
||||
let message = self.message;
|
||||
let message = self.message.unwrap_or("Hello, world!".to_string());
|
||||
let s = format!("say {message}");
|
||||
super::Command(s)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue