File tree 2 files changed +42
-0
lines changed
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -2406,6 +2406,27 @@ impl<T> From<T> for Rc<T> {
2406
2406
}
2407
2407
}
2408
2408
2409
+ #[ cfg( not( no_global_oom_handling) ) ]
2410
+ #[ stable( feature = "shared_from_array" , since = "CURRENT_RUSTC_VERSION" ) ]
2411
+ impl < T , const N : usize > From < [ T ; N ] > for Rc < [ T ] > {
2412
+ /// Converts a [`[T; N]`](prim@array) into an `Rc<[T]>`.
2413
+ ///
2414
+ /// The conversion moves the array into a newly allocated `Rc`.
2415
+ ///
2416
+ /// # Example
2417
+ ///
2418
+ /// ```
2419
+ /// # use std::rc::Rc;
2420
+ /// let original: [i32; 3] = [1, 2, 3];
2421
+ /// let shared: Rc<[i32]> = Rc::from(original);
2422
+ /// assert_eq!(&[1, 2, 3], &shared[..]);
2423
+ /// ```
2424
+ #[ inline]
2425
+ fn from ( v : [ T ; N ] ) -> Rc < [ T ] > {
2426
+ Rc :: < [ T ; N ] > :: from ( v)
2427
+ }
2428
+ }
2429
+
2409
2430
#[ cfg( not( no_global_oom_handling) ) ]
2410
2431
#[ stable( feature = "shared_from_slice" , since = "1.21.0" ) ]
2411
2432
impl < T : Clone > From < & [ T ] > for Rc < [ T ] > {
Original file line number Diff line number Diff line change @@ -3269,6 +3269,27 @@ impl<T> From<T> for Arc<T> {
3269
3269
}
3270
3270
}
3271
3271
3272
+ #[ cfg( not( no_global_oom_handling) ) ]
3273
+ #[ stable( feature = "shared_from_array" , since = "CURRENT_RUSTC_VERSION" ) ]
3274
+ impl < T , const N : usize > From < [ T ; N ] > for Arc < [ T ] > {
3275
+ /// Converts a [`[T; N]`](prim@array) into an `Arc<[T]>`.
3276
+ ///
3277
+ /// The conversion moves the array into a newly allocated `Arc`.
3278
+ ///
3279
+ /// # Example
3280
+ ///
3281
+ /// ```
3282
+ /// # use std::sync::Arc;
3283
+ /// let original: [i32; 3] = [1, 2, 3];
3284
+ /// let shared: Arc<[i32]> = Arc::from(original);
3285
+ /// assert_eq!(&[1, 2, 3], &shared[..]);
3286
+ /// ```
3287
+ #[ inline]
3288
+ fn from ( v : [ T ; N ] ) -> Arc < [ T ] > {
3289
+ Arc :: < [ T ; N ] > :: from ( v)
3290
+ }
3291
+ }
3292
+
3272
3293
#[ cfg( not( no_global_oom_handling) ) ]
3273
3294
#[ stable( feature = "shared_from_slice" , since = "1.21.0" ) ]
3274
3295
impl < T : Clone > From < & [ T ] > for Arc < [ T ] > {
You can’t perform that action at this time.
0 commit comments