diff options
| author | bors <bors@rust-lang.org> | 2017-10-31 23:06:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-10-31 23:06:37 +0000 |
| commit | f3b900cc3b122c7e9eb78ca28bec18df68791b08 (patch) | |
| tree | 0fa55ce4def4412af633d90d87e52c18fe195fc9 /src/libstd | |
| parent | 8b22e70b2de5152db3b0c53cfa16eb96b0b9e40e (diff) | |
| parent | 4c853adce9103b8bc84cd6b0026bcdc2eed7da31 (diff) | |
| download | rust-f3b900cc3b122c7e9eb78ca28bec18df68791b08.tar.gz rust-f3b900cc3b122c7e9eb78ca28bec18df68791b08.zip | |
Auto merge of #44764 - nvzqz:master, r=alexcrichton
Implement TryFrom<&[T]> for &[T; N] There are many cases where a buffer with a static compile-time size is preferred over a slice with a dynamic size. This allows for performing a checked conversion from `&[T]` to `&[T; N]`. This may also lead to compile-time optimizations involving `[T; N]` such as loop unrolling. This is my first PR to Rust, so I'm not sure if discussion of this change should happen here or does it need its own RFC? I figured these changes would be a subset of #33417.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/error.rs | 8 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 2 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 166439692d4..231b0be9276 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -57,6 +57,7 @@ use borrow::Cow; use cell; use char; use convert; +use core::array; use fmt::{self, Debug, Display}; use mem::transmute; use num; @@ -282,6 +283,13 @@ impl Error for num::TryFromIntError { } } +#[unstable(feature = "try_from", issue = "33417")] +impl Error for array::TryFromSliceError { + fn description(&self) -> &str { + self.__description() + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Error for num::ParseFloatError { fn description(&self) -> &str { diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 012883d0853..5cf1d225b90 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -243,6 +243,7 @@ #![feature(allow_internal_unsafe)] #![feature(allow_internal_unstable)] #![feature(align_offset)] +#![feature(array_error_internals)] #![feature(asm)] #![feature(attr_literals)] #![feature(box_syntax)] @@ -267,6 +268,7 @@ #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] #![feature(exact_size_is_empty)] +#![feature(fixed_size_array)] #![feature(float_from_str_radix)] #![feature(fn_traits)] #![feature(fnbox)] |
