File tree 1 file changed +3
-19
lines changed
1 file changed +3
-19
lines changed Original file line number Diff line number Diff line change @@ -751,25 +751,9 @@ pub trait ThinAttributesExt {
751
751
752
752
impl ThinAttributesExt for ThinAttributes {
753
753
fn map_thin_attrs < F > ( self , f : F ) -> Self
754
- where F : FnOnce ( Vec < Attribute > ) -> Vec < Attribute > {
755
-
756
- // This is kinda complicated... Ensure the function is
757
- // always called, and that None inputs or results are
758
- // correctly handled.
759
- if let Some ( mut b) = self {
760
- use std:: mem:: replace;
761
-
762
- let vec = replace ( & mut * b, Vec :: new ( ) ) ;
763
- let vec = f ( vec) ;
764
- if vec. len ( ) == 0 {
765
- None
766
- } else {
767
- replace ( & mut * b, vec) ;
768
- Some ( b)
769
- }
770
- } else {
771
- f ( Vec :: new ( ) ) . into_thin_attrs ( )
772
- }
754
+ where F : FnOnce ( Vec < Attribute > ) -> Vec < Attribute >
755
+ {
756
+ f ( self . map ( |b| * b) . unwrap_or ( Vec :: new ( ) ) ) . into_thin_attrs ( )
773
757
}
774
758
775
759
fn prepend ( self , attrs : ThinAttributes ) -> Self {
You can’t perform that action at this time.
0 commit comments