#tuple #convert #vec #syntax

tuple-conv

Allows converting tuples of one element to vectors

2 stable releases

1.0.1 Sep 8, 2019
1.0.0 Sep 4, 2019

#14 in #tuple

Download history 33/week @ 2022-06-03 11/week @ 2022-06-10 29/week @ 2022-06-17 30/week @ 2022-06-24 86/week @ 2022-07-01 50/week @ 2022-07-08 43/week @ 2022-07-15 55/week @ 2022-07-22 87/week @ 2022-07-29 102/week @ 2022-08-05 44/week @ 2022-08-12 12/week @ 2022-08-19 16/week @ 2022-08-26 48/week @ 2022-09-02 19/week @ 2022-09-09 25/week @ 2022-09-16

111 downloads per month
Used in 2 crates

MIT license

14KB
157 lines

tuple-conv

License: MIT Docs Version Build Status

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.

Example

let t = (0, 1, 2);
let v = t.to_vec();
assert_eq!(v, [0, 1, 2]);

Motivation

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.

Documentation

A more in-depth explanation is available at docs.rs

No runtime deps