mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Use unwrap or default where possible
This commit is contained in:
parent
04a47babdd
commit
89387c51da
2 changed files with 5 additions and 5 deletions
|
@ -49,8 +49,8 @@ fn prompt(options: PromptOptions) -> LuaResult<PromptResult> {
|
|||
PromptKind::Text => {
|
||||
let input: String = Input::with_theme(&theme)
|
||||
.allow_empty(true)
|
||||
.with_prompt(options.text.unwrap_or("".to_string()))
|
||||
.with_initial_text(options.default_string.unwrap_or("".to_string()))
|
||||
.with_prompt(options.text.unwrap_or_default())
|
||||
.with_initial_text(options.default_string.unwrap_or_default())
|
||||
.interact_text()?;
|
||||
Ok(PromptResult::String(input))
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ fn prompt(options: PromptOptions) -> LuaResult<PromptResult> {
|
|||
}
|
||||
PromptKind::Select => {
|
||||
let chosen = Select::with_theme(&prompt_theme())
|
||||
.with_prompt(&options.text.unwrap_or("".to_string()))
|
||||
.with_prompt(&options.text.unwrap_or_default())
|
||||
.items(&options.options.expect("Missing options in prompt options"))
|
||||
.interact_opt()?;
|
||||
Ok(match chosen {
|
||||
|
@ -76,7 +76,7 @@ fn prompt(options: PromptOptions) -> LuaResult<PromptResult> {
|
|||
}
|
||||
PromptKind::MultiSelect => {
|
||||
let chosen = MultiSelect::with_theme(&prompt_theme())
|
||||
.with_prompt(&options.text.unwrap_or("".to_string()))
|
||||
.with_prompt(&options.text.unwrap_or_default())
|
||||
.items(&options.options.expect("Missing options in prompt options"))
|
||||
.interact_opt()?;
|
||||
Ok(match chosen {
|
||||
|
|
|
@ -66,7 +66,7 @@ pub fn create(lua: &'static Lua) -> LuaResult<LuaTable<'static>> {
|
|||
let sched = lua
|
||||
.app_data_ref::<&TaskScheduler>()
|
||||
.expect(ERR_MISSING_SCHEDULER);
|
||||
sched.schedule_wait(secs.unwrap_or(0f64), LuaValue::Thread(thread))
|
||||
sched.schedule_wait(secs.unwrap_or_default(), LuaValue::Thread(thread))
|
||||
},
|
||||
)?
|
||||
.build_readonly()?,
|
||||
|
|
Loading…
Reference in a new issue