[Rust] Option
Typescript:
function practice(nums: number[], index: number): number {
return (nums[index] ?? index) * 5
}
In Rust:
fn practice(nums: Vec<usize>, index: usize) -> uszie {
return nums.get(index).unwrap_or(&index) * 5;
}
Typescript:
function practice(nums: number[], index: number): number {
return (nums[index] ?? index) * 5
}
In Rust:
fn practice(nums: Vec<usize>, index: usize) -> uszie {
return nums.get(index).unwrap_or(&index) * 5;
}