Skip to content

Commit 99ee8e5

Browse files
authored
Merge pull request #1528 from khandrym/modify-alias
Make all new types have UpperCamelCase names in code example in the Aliasing section
2 parents 2c3401c + c3e71e7 commit 99ee8e5

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/types/alias.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,15 @@ must have `UpperCamelCase` names, or the compiler will raise a warning. The
55
exception to this rule are the primitive types: `usize`, `f32`, etc.
66

77
```rust,editable
8-
// `NanoSecond` is a new name for `u64`.
8+
// `NanoSecond`, `Inch`, and `U64` are new names for `u64`.
99
type NanoSecond = u64;
1010
type Inch = u64;
11-
12-
// Use an attribute to silence warning.
13-
#[allow(non_camel_case_types)]
14-
type u64_t = u64;
15-
// TODO ^ Try removing the attribute
11+
type U64 = u64;
1612
1713
fn main() {
18-
// `NanoSecond` = `Inch` = `u64_t` = `u64`.
19-
let nanoseconds: NanoSecond = 5 as u64_t;
20-
let inches: Inch = 2 as u64_t;
14+
// `NanoSecond` = `Inch` = `U64` = `u64`.
15+
let nanoseconds: NanoSecond = 5 as U64;
16+
let inches: Inch = 2 as U64;
2117
2218
// Note that type aliases *don't* provide any extra type safety, because
2319
// aliases are *not* new types

0 commit comments

Comments
 (0)