File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ impl<T> ManuallyDrop<T> {
64
64
/// ```
65
65
#[ must_use = "if you don't need the wrapper, you can use `mem::forget` instead" ]
66
66
#[ stable( feature = "manually_drop" , since = "1.20.0" ) ]
67
- #[ rustc_const_stable( feature = "const_manually_drop" , since = "1.36 .0" ) ]
67
+ #[ rustc_const_stable( feature = "const_manually_drop" , since = "1.32 .0" ) ]
68
68
#[ inline( always) ]
69
69
pub const fn new ( value : T ) -> ManuallyDrop < T > {
70
70
ManuallyDrop { value }
@@ -82,7 +82,7 @@ impl<T> ManuallyDrop<T> {
82
82
/// let _: Box<()> = ManuallyDrop::into_inner(x); // This drops the `Box`.
83
83
/// ```
84
84
#[ stable( feature = "manually_drop" , since = "1.20.0" ) ]
85
- #[ rustc_const_stable( feature = "const_manually_drop" , since = "1.36 .0" ) ]
85
+ #[ rustc_const_stable( feature = "const_manually_drop" , since = "1.32 .0" ) ]
86
86
#[ inline( always) ]
87
87
pub const fn into_inner ( slot : ManuallyDrop < T > ) -> T {
88
88
slot. value
Original file line number Diff line number Diff line change @@ -417,6 +417,33 @@ impl Error {
417
417
Self :: _new ( kind, error. into ( ) )
418
418
}
419
419
420
+ /// Creates a new I/O error from an arbitrary error payload.
421
+ ///
422
+ /// This function is used to generically create I/O errors which do not
423
+ /// originate from the OS itself. It is a shortcut for [`Error::new`]
424
+ /// with [`ErrorKind::Other`].
425
+ ///
426
+ /// # Examples
427
+ ///
428
+ /// ```
429
+ /// #![feature(io_error_other)]
430
+ ///
431
+ /// use std::io::Error;
432
+ ///
433
+ /// // errors can be created from strings
434
+ /// let custom_error = Error::other("oh no!");
435
+ ///
436
+ /// // errors can also be created from other errors
437
+ /// let custom_error2 = Error::other(custom_error);
438
+ /// ```
439
+ #[ unstable( feature = "io_error_other" , issue = "91946" ) ]
440
+ pub fn other < E > ( error : E ) -> Error
441
+ where
442
+ E : Into < Box < dyn error:: Error + Send + Sync > > ,
443
+ {
444
+ Self :: _new ( ErrorKind :: Other , error. into ( ) )
445
+ }
446
+
420
447
fn _new ( kind : ErrorKind , error : Box < dyn error:: Error + Send + Sync > ) -> Error {
421
448
Error { repr : Repr :: Custom ( Box :: new ( Custom { kind, error } ) ) }
422
449
}
You can’t perform that action at this time.
0 commit comments