Skip to content

Commit

Permalink
Update README.md (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
yunjhongwu authored Dec 12, 2023
1 parent b3f2cf1 commit 9dc8d14
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ assert_eq!(x.type_id(), y.type_id()); // Same type: Second
assert_ne!(y.type_id(), z.type_id()); // Different types: Second versus Minute
```

#### Hashable if the underlying type implements `Hash`:

```rust
use std::collections::HashSet;

#[derive(StrongType)]
struct Tag(String);

let mut map = HashSet::<Tag>::new();
map.insert(Tag::new("dev"));
map.insert(Tag::new("prod"));
assert_eq!(map.len(), 2);
```

#### Named integer type with arithmetic operations:

```rust
Expand All @@ -67,9 +81,11 @@ struct Second(i32);

let x = Second::new(2);
let y = Second::new(3);
let z = Second::default();

assert_eq!(x.value(), 2);
assert_eq!(y.value(), 3);
assert_eq!(z.value(), 0);
assert!(x < y);
assert!(y >= x);
assert_eq!(x + y, Second(5));
Expand Down

0 comments on commit 9dc8d14

Please sign in to comment.