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

Basic traits restrictions for Dimension::Pattern #634

Merged
merged 1 commit into from
May 12, 2019

Conversation

termoshtt
Copy link
Member

The Pattern associated type of Dimension is used in several top level API e.g. ArrayBase::dim, but its definition lacks restrictions Eq, Debug, and others. Here is my code:

fn assert_equal_size<A, S1, S2, D>(test: &ArrayBase<S1, D>, truth: &ArrayBase<S2, D>)
where
    A: LinalgScalar,
    S1: Data<Elem = A>,
    S2: Data<Elem = A>,
    D: Dimension,
    D::Pattern: PartialEq + Debug,   // I'd like to remove this line !!
{
    assert_eq!(test.dim(), truth.dim());
}

Summary

  • Add Clone, Debug, PartialEq, Eq, and Default restrictions to Dimension::Pattern
  • Copy is not added because IxDyn is not Copy

Copy link
Member

@jturner314 jturner314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me and AFAIK is not a breaking change (since no external crates can implement Dimension.)

@LukeMathWalker
Copy link
Member

If you run cargo fmt we should be able to merge it without conflicts @termoshtt 🚀

@LukeMathWalker LukeMathWalker merged commit 162fb9b into rust-ndarray:master May 12, 2019
@termoshtt termoshtt deleted the dim_pattern_traits branch August 10, 2019 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants