Skip to content

Commit 5842355

Browse files
committed
Generalize Not and Neg
1 parent ed2eaf7 commit 5842355

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/lib.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,8 +1653,10 @@ mod assign_ops {
16531653
"Implement `self ^= rhs` as elementwise bit xor (in place).\n");
16541654
}
16551655

1656-
impl<A: Clone + Neg<Output=A>, D: Dimension>
1657-
Array<A, D>
1656+
impl<A, S, D> ArrayBase<S, D>
1657+
where A: Clone + Neg<Output=A>,
1658+
S: DataMut<Elem=A>,
1659+
D: Dimension
16581660
{
16591661
/// Perform an elementwise negation of `self`, *in place*.
16601662
pub fn ineg(&mut self)
@@ -1665,20 +1667,23 @@ Array<A, D>
16651667
}
16661668
}
16671669

1668-
impl<A: Clone + Neg<Output=A>, D: Dimension>
1669-
Neg for Array<A, D>
1670+
impl<A, S, D> Neg for ArrayBase<S, D>
1671+
where A: Clone + Neg<Output=A>,
1672+
S: DataMut<Elem=A>,
1673+
D: Dimension
16701674
{
16711675
type Output = Self;
16721676
/// Perform an elementwise negation of `self` and return the result.
1673-
fn neg(mut self) -> Array<A, D>
1674-
{
1677+
fn neg(mut self) -> Self {
16751678
self.ineg();
16761679
self
16771680
}
16781681
}
16791682

1680-
impl<A: Clone + Not<Output=A>, D: Dimension>
1681-
Array<A, D>
1683+
impl<A, S, D> ArrayBase<S, D>
1684+
where A: Clone + Not<Output=A>,
1685+
S: DataMut<Elem=A>,
1686+
D: Dimension
16821687
{
16831688
/// Perform an elementwise unary not of `self`, *in place*.
16841689
pub fn inot(&mut self)
@@ -1689,13 +1694,15 @@ Array<A, D>
16891694
}
16901695
}
16911696

1692-
impl<A: Clone + Not<Output=A>, D: Dimension>
1693-
Not for Array<A, D>
1697+
1698+
impl<A, S, D> Not for ArrayBase<S, D>
1699+
where A: Clone + Not<Output=A>,
1700+
S: DataMut<Elem=A>,
1701+
D: Dimension
16941702
{
16951703
type Output = Self;
16961704
/// Perform an elementwise unary not of `self` and return the result.
1697-
fn not(mut self) -> Array<A, D>
1698-
{
1705+
fn not(mut self) -> Self {
16991706
self.inot();
17001707
self
17011708
}

0 commit comments

Comments
 (0)