-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.rs
More file actions
35 lines (30 loc) · 755 Bytes
/
Copy pathmain.rs
File metadata and controls
35 lines (30 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//! Demonstrates the effect of the `optimized` feature on the code generated by `refined`.
use refined::{boundable::unsigned::LessThan, prelude::*};
type Size = Refinement<usize, LessThan<12>>;
#[no_mangle]
fn month_name(s: &Size) -> &'static str {
const MONTHS: [&str; 12] = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];
MONTHS[**s]
}
fn main() {
let raw_index = std::env::args()
.next_back()
.unwrap()
.parse::<usize>()
.unwrap();
let index = Size::refine(raw_index).unwrap();
println!("{}", month_name(&index));
}