Menu: Difference between revisions

m (moved REBOL to it's proper place alphabetically.)
Line 2,249:
}
print!("Pick a number from 1 to {}: ", items.len());
 
// Read the user input:
stdin.read_line(&mut buffer).unwrap();
println!();
 
matchif let Ok(selected_index) = buffer.trim().parse::<usize>() {
Ok(selection) if 0 < selection && selection <= items.len() =>selected_index {
returnif let Some(selected_item) = items[selection.get(selected_index - 1];) {
}, return selected_item;
_ => { }
},
// The buffer will contain the old input, so we need to clear it before we can
// reuse it.
buffer.clear();
},
}
 
// The buffer will contain the old input, so we need to clear it before we can reuse it.
buffer.clear();
}
}
Anonymous user