File tree Expand file tree Collapse file tree 14 files changed +31
-39
lines changed
Expand file tree Collapse file tree 14 files changed +31
-39
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ impl<T: BinaryViewType> From<Option<T::Scalar>> for BinaryViewScalar<T> {
1616}
1717
1818impl < T : BinaryViewType > BinaryViewScalar < T > {
19- /// Returns the scalar value as [`T ::Scalar`], or `None` if the scalar is null.
19+ /// Returns the scalar value as [`BinaryViewType ::Scalar`], or `None` if the scalar is null.
2020 pub fn value ( & self ) -> Option < & T :: Scalar > {
2121 self . 0 . as_ref ( )
2222 }
@@ -49,8 +49,8 @@ impl BinaryViewTypeUpcast for Scalar {
4949 }
5050}
5151
52- impl < T : BinaryViewType > Into < Scalar > for BinaryViewScalar < T > {
53- fn into ( self ) -> Scalar {
54- T :: upcast ( self )
52+ impl < T : BinaryViewType > From < BinaryViewScalar < T > > for Scalar {
53+ fn from ( val : BinaryViewScalar < T > ) -> Self {
54+ T :: upcast ( val )
5555 }
5656}
Original file line number Diff line number Diff line change @@ -28,8 +28,8 @@ impl ScalarOps for BoolScalar {
2828 }
2929}
3030
31- impl Into < Scalar > for BoolScalar {
32- fn into ( self ) -> Scalar {
33- Scalar :: Bool ( self )
31+ impl From < BoolScalar > for Scalar {
32+ fn from ( val : BoolScalar ) -> Self {
33+ Scalar :: Bool ( val )
3434 }
3535}
Original file line number Diff line number Diff line change @@ -88,11 +88,7 @@ impl VectorOps for BoolVector {
8888 debug_assert ! ( index < self . len( ) ) ;
8989
9090 let is_valid = self . validity . value ( index) ;
91- let value = if is_valid {
92- Some ( self . bits . value ( index) )
93- } else {
94- None
95- } ;
91+ let value = is_valid. then ( || self . bits . value ( index) ) ;
9692
9793 Scalar :: Bool ( value. into ( ) )
9894 }
Original file line number Diff line number Diff line change @@ -162,11 +162,7 @@ impl<D: NativeDecimalType> VectorOps for DVector<D> {
162162 debug_assert ! ( index < self . len( ) ) ;
163163
164164 let is_valid = self . validity . value ( index) ;
165- let value = if is_valid {
166- Some ( self . elements [ index] )
167- } else {
168- None
169- } ;
165+ let value = is_valid. then ( || self . elements [ index] ) ;
170166
171167 // SAFETY: We have already checked the validity on construction of the vector
172168 Scalar :: Decimal ( unsafe { DScalar :: < D > :: new_unchecked ( self . ps , value) } . into ( ) )
Original file line number Diff line number Diff line change @@ -47,9 +47,9 @@ impl ScalarOps for DecimalScalar {
4747 }
4848}
4949
50- impl Into < Scalar > for DecimalScalar {
51- fn into ( self ) -> Scalar {
52- Scalar :: Decimal ( self )
50+ impl From < DecimalScalar > for Scalar {
51+ fn from ( val : DecimalScalar ) -> Self {
52+ Scalar :: Decimal ( val )
5353 }
5454}
5555
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ impl VectorOps for DecimalVector {
4242 }
4343
4444 fn scalar_at ( & self , index : usize ) -> Scalar {
45- match_each_dvector ! ( self , |v| { v. scalar_at( index) . into ( ) } )
45+ match_each_dvector ! ( self , |v| { v. scalar_at( index) } )
4646 }
4747
4848 fn slice ( & self , range : impl RangeBounds < usize > + Clone + Debug ) -> Self {
Original file line number Diff line number Diff line change @@ -35,8 +35,8 @@ impl ScalarOps for FixedSizeListScalar {
3535 }
3636}
3737
38- impl Into < Scalar > for FixedSizeListScalar {
39- fn into ( self ) -> Scalar {
40- Scalar :: FixedSizeList ( self )
38+ impl From < FixedSizeListScalar > for Scalar {
39+ fn from ( val : FixedSizeListScalar ) -> Self {
40+ Scalar :: FixedSizeList ( val )
4141 }
4242}
Original file line number Diff line number Diff line change @@ -31,8 +31,8 @@ impl ScalarOps for ListViewScalar {
3131 }
3232}
3333
34- impl Into < Scalar > for ListViewScalar {
35- fn into ( self ) -> Scalar {
36- Scalar :: List ( self )
34+ impl From < ListViewScalar > for Scalar {
35+ fn from ( val : ListViewScalar ) -> Self {
36+ Scalar :: List ( val )
3737 }
3838}
Original file line number Diff line number Diff line change @@ -213,7 +213,7 @@ impl VectorOps for ListViewVector {
213213
214214 fn scalar_at ( & self , index : usize ) -> Scalar {
215215 assert ! ( index < self . len( ) ) ;
216- ListViewScalar :: new ( self . slice ( index..index + 1 ) . into ( ) ) . into ( )
216+ ListViewScalar :: new ( self . slice ( index..index + 1 ) ) . into ( )
217217 }
218218
219219 fn slice ( & self , _range : impl RangeBounds < usize > + Clone + Debug ) -> Self {
Original file line number Diff line number Diff line change @@ -17,8 +17,8 @@ impl ScalarOps for NullScalar {
1717 }
1818}
1919
20- impl Into < Scalar > for NullScalar {
21- fn into ( self ) -> Scalar {
22- Scalar :: Null ( self )
20+ impl From < NullScalar > for Scalar {
21+ fn from ( val : NullScalar ) -> Self {
22+ Scalar :: Null ( val )
2323 }
2424}
You can’t perform that action at this time.
0 commit comments