Rust: Tracking issue for FixedSizeArray trait

Created on 13 Aug 2015  Â·  9Comments  Â·  Source: rust-lang/rust

This is a tracking issue for the unstable fixed_size_array feature in the standard library. This is likely to be deprecated and removed in favor of generic integers one day, and in the meantime there are not many consumers of it.

A-const-generics A-slice B-unstable C-tracking-issue Libs-Tracked T-libs

Most helpful comment

I wrote https://github.com/rust-lang/rfcs/pull/1915 about extending and stabilizing this trait.

All 9 comments

Note that the fixed_size_array feature specifically covers the FixedSizeArray trait. There's some other code in core::array, but it's all implicitly stable.

The FixedSizeArray trait would be great, except for many uses the ranges of sizes it's implemented for simply isn't what you need, and there is no way to expand it. Thus it is mostly useless in the current form.

Could the compiler magically have an "infinite" (generated on demand) number of impls of FixedSizeArray?

If that happens and the type parameter is made into an associated type (and maybe an associated const for the size is added), then most of the other impls that currently only go up to N=32 could be made generic impl<A: FixedSizeArray> … for A.

If/when the issue of using associated consts like consts is resolved, that is, allow [i32; A::LEN] to compile; then an infinite number of FixedSizeArray impls would give us the same thing as generic integer parameters.

This suggests to me that completing associated constants is basically the same problem as allowing generic integer parameters.

for now FixedSizeArray could be moved to a crate since it doesn't use any compiler magic anyway

Triage: no changes

Something did change in https://github.com/rust-lang/rust/pull/28088: this trait is now implemented for all sizes:

unsafe impl<T, A: Unsize<[T]>> FixedSizeArray<T> for A

The Unsize trait is also unstable: https://github.com/rust-lang/rust/issues/27732

I wrote https://github.com/rust-lang/rfcs/pull/1915 about extending and stabilizing this trait.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drewcrawford picture drewcrawford  Â·  3Comments

SharplEr picture SharplEr  Â·  3Comments

modsec picture modsec  Â·  3Comments

cuviper picture cuviper  Â·  3Comments

behnam picture behnam  Â·  3Comments