Skip to content

Commit

Permalink
Remove paste dependency (#1266)
Browse files Browse the repository at this point in the history
* remove paste dependency

* unsilence many warnings
  • Loading branch information
Robbepop authored Oct 29, 2024
1 parent ef5cdf4 commit 29723a1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ exclude.workspace = true
libm = "0.2.8"
num-traits = { workspace = true }
downcast-rs = { version = "1.2", default-features = false }
paste = "1"

[dev-dependencies]
rand = "0.8.5"
Expand Down
39 changes: 18 additions & 21 deletions crates/core/src/untyped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use core::{
fmt::{self, Display},
ops::{Neg, Shl, Shr},
};
use paste::paste;

/// An untyped value.
///
Expand Down Expand Up @@ -1479,27 +1478,25 @@ where

macro_rules! impl_encode_untyped_slice {
( $n:literal $( $tuple:ident )* ) => {
paste! {
impl<$($tuple),*> EncodeUntypedSlice for ($($tuple,)*)
where
impl<$($tuple),*> EncodeUntypedSlice for ($($tuple,)*)
where
$(
$tuple: Into<UntypedVal>
),*
{
#[allow(non_snake_case)]
#[inline]
fn encode_untyped_slice<'a>(self, results: &'a mut [UntypedVal]) -> Result<(), UntypedError> {
let Ok(_results) = <&'a mut [UntypedVal; $n]>::try_from(results) else {
return Err(UntypedError::invalid_len())
};
let ( $( $tuple ,)* ) = self;
let mut _i = 0;
$(
$tuple: Into<UntypedVal>
),*
{
#[allow(non_snake_case)]
#[inline]
fn encode_untyped_slice(self, results: &mut [UntypedVal]) -> Result<(), UntypedError> {
match results {
[ $( [< _results_ $tuple >] ,)* ] => {
let ( $( [< _self_ $tuple >] ,)* ) = self;
$(
*[< _results_ $tuple >] = <$tuple as Into<UntypedVal>>::into([< _self_ $tuple >]);
)*
Ok(())
}
_ => Err(UntypedError::invalid_len())
}
}
_results[_i] = <$tuple as Into<UntypedVal>>::into($tuple);
_i += 1;
)*
Ok(())
}
}
};
Expand Down

0 comments on commit 29723a1

Please sign in to comment.