@@ -303,6 +303,32 @@ impl CqlVarint {
303303 }
304304}
305305
306+ /// Compares two [`CqlVarint`] values after normalization.
307+ ///
308+ /// # Example
309+ ///
310+ /// ```rust
311+ /// # use scylla_cql::frame::value::CqlVarint;
312+ /// let non_normalized_bytes = vec![0x00, 0x01];
313+ /// let normalized_bytes = vec![0x01];
314+ /// assert_eq!(
315+ /// CqlVarint::from_signed_bytes_be(non_normalized_bytes),
316+ /// CqlVarint::from_signed_bytes_be(normalized_bytes)
317+ /// );
318+ /// ```
319+ impl PartialEq for CqlVarint {
320+ fn eq ( & self , other : & Self ) -> bool {
321+ self . as_normalized_slice ( ) == other. as_normalized_slice ( )
322+ }
323+ }
324+
325+ /// Computes the hash of normalized [`CqlVarint`].
326+ impl std:: hash:: Hash for CqlVarint {
327+ fn hash < H : std:: hash:: Hasher > ( & self , state : & mut H ) {
328+ self . as_normalized_slice ( ) . hash ( state)
329+ }
330+ }
331+
306332#[ cfg( feature = "num-bigint-03" ) ]
307333impl From < num_bigint_03:: BigInt > for CqlVarint {
308334 fn from ( value : num_bigint_03:: BigInt ) -> Self {
@@ -331,32 +357,6 @@ impl From<CqlVarint> for num_bigint_04::BigInt {
331357 }
332358}
333359
334- /// Compares two [`CqlVarint`] values after normalization.
335- ///
336- /// # Example
337- ///
338- /// ```rust
339- /// # use scylla_cql::frame::value::CqlVarint;
340- /// let non_normalized_bytes = vec![0x00, 0x01];
341- /// let normalized_bytes = vec![0x01];
342- /// assert_eq!(
343- /// CqlVarint::from_signed_bytes_be(non_normalized_bytes),
344- /// CqlVarint::from_signed_bytes_be(normalized_bytes)
345- /// );
346- /// ```
347- impl PartialEq for CqlVarint {
348- fn eq ( & self , other : & Self ) -> bool {
349- self . as_normalized_slice ( ) == other. as_normalized_slice ( )
350- }
351- }
352-
353- /// Computes the hash of normalized [`CqlVarint`].
354- impl std:: hash:: Hash for CqlVarint {
355- fn hash < H : std:: hash:: Hasher > ( & self , state : & mut H ) {
356- self . as_normalized_slice ( ) . hash ( state)
357- }
358- }
359-
360360/// Native CQL `decimal` representation.
361361///
362362/// Represented as a pair:
0 commit comments