8000 Basic traits restrictions for Dimension::Pattern by termoshtt · Pull Request #634 · rust-ndarray/ndarray · GitHub
[go: up one dir, main page]

Skip to content

Basic traits restrictions for Dimension::Pattern#634

Merged
LukeMathWalker merged 1 commit intorust-ndarray:masterfrom
termoshtt:dim_pattern_traits
May 12, 2019
Merged

Basic traits restrictions for Dimension::Pattern#634
LukeMathWalker merged 1 commit intorust-ndarray:masterfrom
termoshtt:dim_pattern_traits

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 🚀

@termoshtt termoshtt force-pushed the dim_pattern_traits branch from 4c41a74 to 4a37172 Compare May 12, 2019 15:39
@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

0