File tree 2 files changed +36
-0
lines changed
2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -119,13 +119,29 @@ impl From<String> for Box<Error + Send + Sync> {
119
119
}
120
120
}
121
121
122
+ #[ stable( feature = "string_box_error" , since = "1.7.0" ) ]
123
+ impl From < String > for Box < Error > {
124
+ fn from ( str_err : String ) -> Box < Error > {
125
+ let err1: Box < Error + Send + Sync > = From :: from ( str_err) ;
126
+ let err2: Box < Error > = err1;
127
+ err2
128
+ }
129
+ }
130
+
122
131
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
123
132
impl < ' a , ' b > From < & ' b str > for Box < Error + Send + Sync + ' a > {
124
133
fn from ( err : & ' b str ) -> Box < Error + Send + Sync + ' a > {
125
134
From :: from ( String :: from ( err) )
126
135
}
127
136
}
128
137
138
+ #[ stable( feature = "string_box_error" , since = "1.7.0" ) ]
139
+ impl < ' a > From < & ' a str > for Box < Error > {
140
+ fn from ( err : & ' a str ) -> Box < Error > {
141
+ From :: from ( String :: from ( err) )
142
+ }
143
+ }
144
+
129
145
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
130
146
impl Error for str:: ParseBoolError {
131
147
fn description ( & self ) -> & str { "failed to parse bool" }
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // Ensure that both `Box<Error + Send + Sync>` and `Box<Error>` can be obtained from `String`.
12
+
13
+ use std:: error:: Error ;
14
+
15
+ fn main ( ) {
16
+ let _err1: Box < Error + Send + Sync > = From :: from ( "test" . to_string ( ) ) ;
17
+ let _err2: Box < Error > = From :: from ( "test" . to_string ( ) ) ;
18
+ let _err3: Box < Error + Send + Sync + ' static > = From :: from ( "test" ) ;
19
+ let _err4: Box < Error > = From :: from ( "test" ) ;
20
+ }
You can’t perform that action at this time.
0 commit comments