Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Debug trait to pub trait Num #319

Closed

Conversation

hamirmahal
Copy link

fixes #318.

@hamirmahal hamirmahal changed the title test: if pub trait Num impl Debug add Debug trait to pub trait Num Apr 12, 2024
@cuviper
Copy link
Member

cuviper commented Apr 12, 2024

Sorry, no, this would be a breaking change. I don't think Debug is fundamental to being numeric either.

@cuviper cuviper closed this Apr 12, 2024
@hamirmahal
Copy link
Author

hamirmahal commented Apr 12, 2024

I understand. Are you also against pub trait Num implementing std::iter::Sum?

#[test]
fn test_sum() {
    use num_traits::Num;
    pub struct LengthNArrayOfTypeT<const N: usize, T: Num>([T; N]);
    impl<const N: usize, T: Clone + Num> LengthNArrayOfTypeT<N, T> {
        fn dot(&self, v: &LengthNArrayOfTypeT<N, T>) -> T {
            self.0
                .iter()
                .zip(v.0.iter())
                .map(|(a, b)| a.clone() * b.clone())
                .sum()
        }
    }
}

doesn't compile, but it could if pub trait Num implements std::iter::Sum, if I'm not mistaken.

@cuviper
Copy link
Member

cuviper commented Apr 12, 2024

Any added requirements are equally breaking changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

struct built on top of pub trait Num can't compile if pub trait Num doesn't impl Debug
2 participants