Skip to content

Commit b7ba2c3

Browse files
authored
Raw-rs: Remove fortuples dependency (#2082)
Remove fortuples from Raw-rs
1 parent 4df7803 commit b7ba2c3

File tree

3 files changed

+55
-62
lines changed

3 files changed

+55
-62
lines changed

libraries/raw-rs/Cargo.lock

Lines changed: 13 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libraries/raw-rs/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ build-camera-data = { path = "build-camera-data" }
3131
# Required dependencies
3232
bitstream-io = "2.5.3"
3333
num_enum = "0.7.3"
34-
fortuples = "0.9.1"
3534
thiserror = "1.0.64"
3635

3736
# Optional dependencies (should be dev dependencies, but Cargo currently doesn't allow optional dev dependencies)

libraries/raw-rs/src/processing.rs

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::CHANNELS_IN_RGB;
2-
use fortuples::fortuples;
32

43
#[derive(Clone, Copy)]
54
pub struct RawPixel {
@@ -25,21 +24,30 @@ impl<T: Fn(RawPixel) -> u16> RawPixelTransform for T {
2524
}
2625
}
2726

28-
fortuples! {
29-
#[tuples::min_size(1)]
30-
#[tuples::max_size(8)]
31-
impl RawPixelTransform for #Tuple
32-
where
33-
#(#Member: RawPixelTransform),*
34-
{
35-
fn apply(&mut self, mut pixel: RawPixel) -> u16 {
36-
#(pixel.value = #self.apply(pixel);)*
27+
macro_rules! impl_raw_pixel_transform {
28+
($($idx:tt $t:tt),+) => {
29+
impl<$($t,)+> RawPixelTransform for ($($t,)+)
30+
where
31+
$($t: RawPixelTransform,)+
32+
{
33+
fn apply(&mut self, mut pixel: RawPixel) -> u16 {
34+
$(pixel.value = self.$idx.apply(pixel);)*
3735

38-
pixel.value
39-
}
40-
}
36+
pixel.value
37+
}
38+
}
39+
};
4140
}
4241

42+
impl_raw_pixel_transform!(0 A);
43+
impl_raw_pixel_transform!(0 A, 1 B);
44+
impl_raw_pixel_transform!(0 A, 1 B, 2 C);
45+
impl_raw_pixel_transform!(0 A, 1 B, 2 C, 3 D);
46+
impl_raw_pixel_transform!(0 A, 1 B, 2 C, 3 D, 4 E);
47+
impl_raw_pixel_transform!(0 A, 1 B, 2 C, 3 D, 4 E, 5 F);
48+
impl_raw_pixel_transform!(0 A, 1 B, 2 C, 3 D, 4 E, 5 F, 6 G);
49+
impl_raw_pixel_transform!(0 A, 1 B, 2 C, 3 D, 4 E, 5 F, 6 G, 7 H);
50+
4351
pub trait PixelTransform {
4452
fn apply(&mut self, pixel: Pixel) -> [u16; CHANNELS_IN_RGB];
4553
}
@@ -50,17 +58,26 @@ impl<T: Fn(Pixel) -> [u16; CHANNELS_IN_RGB]> PixelTransform for T {
5058
}
5159
}
5260

53-
fortuples! {
54-
#[tuples::min_size(1)]
55-
#[tuples::max_size(8)]
56-
impl PixelTransform for #Tuple
57-
where
58-
#(#Member: PixelTransform),*
59-
{
60-
fn apply(&mut self, mut pixel: Pixel) -> [u16; CHANNELS_IN_RGB] {
61-
#(pixel.values = #self.apply(pixel);)*
61+
macro_rules! impl_pixel_transform {
62+
($($idx:tt $t:tt),+) => {
63+
impl<$($t,)+> PixelTransform for ($($t,)+)
64+
where
65+
$($t: PixelTransform,)+
66+
{
67+
fn apply(&mut self, mut pixel: Pixel) -> [u16; CHANNELS_IN_RGB] {
68+
$(pixel.values = self.$idx.apply(pixel);)*
6269

63-
pixel.values
64-
}
65-
}
70+
pixel.values
71+
}
72+
}
73+
};
6674
}
75+
76+
impl_pixel_transform!(0 A);
77+
impl_pixel_transform!(0 A, 1 B);
78+
impl_pixel_transform!(0 A, 1 B, 2 C);
79+
impl_pixel_transform!(0 A, 1 B, 2 C, 3 D);
80+
impl_pixel_transform!(0 A, 1 B, 2 C, 3 D, 4 E);
81+
impl_pixel_transform!(0 A, 1 B, 2 C, 3 D, 4 E, 5 F);
82+
impl_pixel_transform!(0 A, 1 B, 2 C, 3 D, 4 E, 5 F, 6 G);
83+
impl_pixel_transform!(0 A, 1 B, 2 C, 3 D, 4 E, 5 F, 6 G, 7 H);

0 commit comments

Comments
 (0)