File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ impl Bit {
4949
5050 #[ cfg( any( feature = "postgres" , feature = "sqlx" , feature = "diesel" ) ) ]
5151 pub ( crate ) fn from_sql ( buf : & [ u8 ] ) -> Result < Bit , Box < dyn std:: error:: Error + Sync + Send > > {
52- let len = i32:: from_be_bytes ( buf[ 0 ..4 ] . try_into ( ) ?) as usize ;
52+ let len = i32:: from_be_bytes ( buf[ 0 ..4 ] . try_into ( ) ?) . try_into ( ) ? ;
5353 let data = buf[ 4 ..4 + ( len + 7 ) / 8 ] . to_vec ( ) ;
5454
5555 Ok ( Bit { len, data } )
Original file line number Diff line number Diff line change @@ -69,9 +69,9 @@ impl SparseVector {
6969
7070 /// Returns the sparse vector as a `Vec<f32>`.
7171 pub fn to_vec ( & self ) -> Vec < f32 > {
72- let mut vec = vec ! [ 0.0 ; self . dim as usize ] ;
72+ let mut vec = vec ! [ 0.0 ; self . dim. try_into ( ) . unwrap ( ) ] ;
7373 for ( i, v) in self . indices . iter ( ) . zip ( & self . values ) {
74- vec[ * i as usize ] = * v;
74+ vec[ usize :: try_from ( * i ) . unwrap ( ) ] = * v;
7575 }
7676 vec
7777 }
@@ -81,7 +81,7 @@ impl SparseVector {
8181 buf : & [ u8 ] ,
8282 ) -> Result < SparseVector , Box < dyn std:: error:: Error + Sync + Send > > {
8383 let dim = i32:: from_be_bytes ( buf[ 0 ..4 ] . try_into ( ) ?) ;
84- let nnz = i32:: from_be_bytes ( buf[ 4 ..8 ] . try_into ( ) ?) as usize ;
84+ let nnz = i32:: from_be_bytes ( buf[ 4 ..8 ] . try_into ( ) ?) . try_into ( ) ? ;
8585 let unused = i32:: from_be_bytes ( buf[ 8 ..12 ] . try_into ( ) ?) ;
8686 if unused != 0 {
8787 return Err ( "expected unused to be 0" . into ( ) ) ;
You can’t perform that action at this time.
0 commit comments