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 {
49
49
50
50
#[ cfg( any( feature = "postgres" , feature = "sqlx" , feature = "diesel" ) ) ]
51
51
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 ( ) ? ;
53
53
let data = buf[ 4 ..4 + ( len + 7 ) / 8 ] . to_vec ( ) ;
54
54
55
55
Ok ( Bit { len, data } )
Original file line number Diff line number Diff line change @@ -69,9 +69,9 @@ impl SparseVector {
69
69
70
70
/// Returns the sparse vector as a `Vec<f32>`.
71
71
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 ( ) ] ;
73
73
for ( i, v) in self . indices . iter ( ) . zip ( & self . values ) {
74
- vec[ * i as usize ] = * v;
74
+ vec[ usize :: try_from ( * i ) . unwrap ( ) ] = * v;
75
75
}
76
76
vec
77
77
}
@@ -81,7 +81,7 @@ impl SparseVector {
81
81
buf : & [ u8 ] ,
82
82
) -> Result < SparseVector , Box < dyn std:: error:: Error + Sync + Send > > {
83
83
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 ( ) ? ;
85
85
let unused = i32:: from_be_bytes ( buf[ 8 ..12 ] . try_into ( ) ?) ;
86
86
if unused != 0 {
87
87
return Err ( "expected unused to be 0" . into ( ) ) ;
You can’t perform that action at this time.
0 commit comments