| Crates.io | tuple-conv |
| lib.rs | tuple-conv |
| version | 1.0.1 |
| created_at | 2019-09-04 22:45:34.182394+00 |
| updated_at | 2019-09-08 22:43:26.581247+00 |
| description | Allows converting tuples of one element to vectors |
| homepage | |
| repository | https://github.com/sharnoff/tuple-conv |
| max_upload_size | |
| id | 162299 |
| size | 16,540 |
tuple-conv provides simple tools for converting tuples with repeated elements
into vectors of that type. Repeated tuples are of the form: (T, T, ... T) -
composed entirely of elements with type T.
More information can be found in the documentation.
let t = (0, 1, 2);
let v = t.to_vec();
assert_eq!(v, [0, 1, 2]);
The primary motivation for this package is syntactic elegance. In Python, we can easily convert tuples to lists with:
t = (1, 2, 3)
l = list(t)
This isn't typically possible in Rust, however, because each tuple is a
distinct type. This isn't too bad, but repeated API calls warrant better
syntax. tuple-conv provides a way of removing vec![] macro calls and get a
bit more syntactical sugar without making every part of the public-facing API a
macro.
A more in-depth explanation is available at docs.rs