Skip to content

Commit

Permalink
remove explicit enum discriminants to unblock the build
Browse files Browse the repository at this point in the history
  • Loading branch information
ejmahler committed Feb 6, 2024
1 parent 5695fb3 commit 4c723ea
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
22 changes: 15 additions & 7 deletions src/algorithm/radixn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,24 @@ use super::butterflies::{Butterfly2, Butterfly3, Butterfly4, Butterfly5, Butterf

#[repr(u8)]
enum InternalRadixFactor<T> {
Factor2(Butterfly2<T>) = 2,
Factor3(Butterfly3<T>) = 3,
Factor4(Butterfly4<T>) = 4,
Factor5(Butterfly5<T>) = 5,
Factor6(Butterfly6<T>) = 6,
Factor7(Butterfly7<T>) = 7,
Factor2(Butterfly2<T>),
Factor3(Butterfly3<T>),
Factor4(Butterfly4<T>),
Factor5(Butterfly5<T>),
Factor6(Butterfly6<T>),
Factor7(Butterfly7<T>),
}
impl<T> InternalRadixFactor<T> {
pub const fn radix(&self) -> usize {
unsafe { *(self as *const Self as *const u8) as usize }
// note: if we had rustc 1.66, we could just turn these values explicit discriminators on the enum
match self {
InternalRadixFactor::Factor2(_) => 2,
InternalRadixFactor::Factor3(_) => 3,
InternalRadixFactor::Factor4(_) => 4,
InternalRadixFactor::Factor5(_) => 5,
InternalRadixFactor::Factor6(_) => 6,
InternalRadixFactor::Factor7(_) => 7,
}
}
}

Expand Down
22 changes: 15 additions & 7 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,23 @@ macro_rules! boilerplate_fft {
#[repr(u8)]
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum RadixFactor {
Factor2 = 2,
Factor3 = 3,
Factor4 = 4,
Factor5 = 5,
Factor6 = 6,
Factor7 = 7,
Factor2,
Factor3,
Factor4,
Factor5,
Factor6,
Factor7,
}
impl RadixFactor {
pub const fn radix(&self) -> usize {
unsafe { *(self as *const Self as *const u8) as usize }
// note: if we had rustc 1.66, we could just turn these values explicit discriminators on the enum
match self {
RadixFactor::Factor2 => 2,
RadixFactor::Factor3 => 3,
RadixFactor::Factor4 => 4,
RadixFactor::Factor5 => 5,
RadixFactor::Factor6 => 6,
RadixFactor::Factor7 => 7,
}
}
}

0 comments on commit 4c723ea

Please sign in to comment.