Skip to content

Commit a52351e

Browse files
committed
Update README
1 parent e91713c commit a52351e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ For example, to define a function to zip a pair of tuples into a tuple of pairs:
88
```rust
99
#[typle(Tuple for 0..=12)]
1010
pub fn zip<A: Tuple, B: Tuple>(
11-
a: A,
12-
b: B
13-
) -> typle_for!(i in .. => (A<{i}>, B<{i}>))
11+
a: A, // (A0, A1,...)
12+
b: B, // (B0, B1,...)
13+
) -> typle_for!(i in .. => (A<{i}>, B<{i}>)) // ((A0, B0), (A1, B1),...)
1414
{
15-
typle_for!(i in .. => (a[[i]], b[[i]]))
15+
typle_for!(i in .. => (a[[i]], b[[i]])) // ((a.0, b.0), (a.1, b.1),...)
1616
}
1717
```
1818

1919
The types `A` and `B` are generic but are constrained to be tuples. The tuples
20-
can have 0 to 12 components of any (sized) type, but both parameters must have the
20+
can have 0 to 12 components of any (sized) type, but both tuples must have the
2121
same length.
2222

2323
```rust
@@ -26,8 +26,8 @@ assert_eq!(
2626
(("LHR", 51.5), ("FCO", 41.8), ("ZRH", 47.5))
2727
);
2828
assert_eq!(
29-
zip((2.0, "test"), (9u8, ())),
30-
((2.0, 9u8), ("test", ()))
29+
zip((2.0, "test"), (Some(9u8), ('a', 'b'))),
30+
((2.0, Some(9u8)), ("test", ('a', 'b')))
3131
);
3232
assert_eq!(
3333
zip((), ()),
@@ -37,7 +37,7 @@ assert_eq!(
3737

3838
A common use of `typle` is to implement a trait for tuples of multiple lengths.
3939
Compared to using declarative macros, the `typle` code looks more Rust-like and
40-
provides simple access to individual components.
40+
provides access to individual components and their position.
4141

4242
For example the `Hash` implementation for tuples simply hashes each component of
4343
the tuple in order.

tests/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ fn test_zip() {
2929
(("LHR", 51.5), ("FCO", 41.8), ("ZRH", 47.5))
3030
);
3131
assert_eq!(
32-
zip((2.0, "test"), (9u8, ())),
33-
((2.0, 9u8), ("test", ()))
32+
zip((2.0, "test"), (Some(9u8), ('a', 'b'))),
33+
((2.0, Some(9u8)), ("test", ('a', 'b')))
3434
);
3535
assert_eq!(
3636
zip((), ()),

0 commit comments

Comments
 (0)