File tree Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,16 @@ impl From<&'_ &'static str> for OsStr {
127127 }
128128}
129129
130+ #[ cfg( feature = "string" ) ]
131+ impl From < Cow < ' static , str > > for OsStr {
132+ fn from ( cow : Cow < ' static , str > ) -> Self {
133+ match cow {
134+ Cow :: Borrowed ( s) => Self :: from ( s) ,
135+ Cow :: Owned ( s) => Self :: from ( s) ,
136+ }
137+ }
138+ }
139+
130140impl From < OsStr > for std:: ffi:: OsString {
131141 fn from ( name : OsStr ) -> Self {
132142 name. name . into_os_string ( )
Original file line number Diff line number Diff line change @@ -76,6 +76,16 @@ impl From<&'_ &'static str> for Str {
7676 }
7777}
7878
79+ #[ cfg( feature = "string" ) ]
80+ impl From < Cow < ' static , str > > for Str {
81+ fn from ( cow : Cow < ' static , str > ) -> Self {
82+ match cow {
83+ Cow :: Borrowed ( s) => Self :: from ( s) ,
84+ Cow :: Owned ( s) => Self :: from ( s) ,
85+ }
86+ }
87+ }
88+
7989impl From < Str > for String {
8090 fn from ( name : Str ) -> Self {
8191 name. name . into_string ( )
Original file line number Diff line number Diff line change @@ -187,6 +187,15 @@ impl From<&'_ &'static str> for StyledStr {
187187 }
188188}
189189
190+ impl From < Cow < ' static , str > > for StyledStr {
191+ fn from ( cow : Cow < ' static , str > ) -> Self {
192+ match cow {
193+ Cow :: Borrowed ( s) => StyledStr :: from ( s) ,
194+ Cow :: Owned ( s) => StyledStr :: from ( s) ,
195+ }
196+ }
197+ }
198+
190199impl std:: fmt:: Write for StyledStr {
191200 #[ inline]
192201 fn write_str ( & mut self , s : & str ) -> Result < ( ) , std:: fmt:: Error > {
Original file line number Diff line number Diff line change @@ -78,6 +78,13 @@ impl From<Id> for Str {
7878 }
7979}
8080
81+ #[ cfg( feature = "string" ) ]
82+ impl From < Cow < ' static , str > > for Id {
83+ fn from ( name : Cow < ' static , str > ) -> Self {
84+ Self ( name. into ( ) )
85+ }
86+ }
87+
8188impl From < Id > for String {
8289 fn from ( name : Id ) -> Self {
8390 Str :: from ( name) . into ( )
You can’t perform that action at this time.
0 commit comments