MCPcopy Create free account
hub / github.com/Apress/beginning-rust-2e / get_third

Function get_third

Source Code/19-32.rs:4–10  ·  view source on GitHub ↗
(s: &[f64])

Source from the content-addressed store, hash-verified

2None, Some(4.3)*/
3fn main() {
4 fn get_third(s: &[f64]) -> Option<f64> {
5 if s.len() >= 3 {
6 Some(s[2])
7 } else {
8 None
9 }
10 }
11 print!("{:?}, {:?}",
12 get_third(&[3.1, 3.2]),
13 get_third(&[4.1, 4.2, 4.3, 4.4]));

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected