検索
Results of 1 - 1 of about 1 for years (0.004 sec.)
- New Type Idiom - Rust By Example 日本語版 9414
- Introduction 1. Hello World ❱ 1.1. コメント 1.2. フォーマットしてプリント ❱ 1.2.1. デバッグ 1.2.
...
e, an age verification function that checks age in years, must be given a value of type Years . struct Year...
s(i64); struct Days(i64); impl Years { pub fn to_days(&self) -> Days { Days(self.0 * 36...
5) } } impl Days { /// truncates partial years pub fn to_years(&self) -> Years { Years(self.0 / 3...
65) } } fn old_enough(age: &Years) -> bool { age.0 >= 18 } fn main() { let age = Yea...
- https://man.plustar.jp/rust/example/generics/new_types.html - [similar]
PREV
1
NEXT