Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic to determine size at compile time #26865

Closed
Wmaxlees opened this issue Jul 7, 2015 · 2 comments
Closed

Generic to determine size at compile time #26865

Wmaxlees opened this issue Jul 7, 2015 · 2 comments

Comments

@Wmaxlees
Copy link

Wmaxlees commented Jul 7, 2015

It would be nice to be able to make a datatype like the following:

type tname<N> = Vec<[int; N]>;

Where N is not a type but an integer. So, for example:

let instance = tname::<5>::new();

would create an instance of Vec<int; 5]>

@steveklabnik
Copy link
Member

We do have http://doc.rust-lang.org/std/mem/fn.size_of.html to determine size at compile time, but it doesn't seem this is exactly what you're talking about.

To put a 5 in a type position like this, we would need rust-lang/rfcs#1038 , I think, and so this feels like a duplicate of that to me.

@Wmaxlees
Copy link
Author

Wmaxlees commented Jul 7, 2015

Yeah I think that it is a duplicate of that other issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants