Skip to content

Commit

Permalink
Move Sized requirement for CharacterSet trait
Browse files Browse the repository at this point in the history
  • Loading branch information
botahamec committed Jul 30, 2023
1 parent 6261e57 commit fb66891
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/csets.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use std::collections::HashSet;

pub trait CharacterSet: Sized {
pub trait CharacterSet {
fn contains(&self, ch: char) -> bool;

fn union<Other: CharacterSet>(self, other: Other) -> CharacterSetUnion<Self, Other> {
fn union<Other: CharacterSet>(self, other: Other) -> CharacterSetUnion<Self, Other>
where
Self: Sized,
{
CharacterSetUnion {
first: self,
second: other,
Expand All @@ -13,21 +16,30 @@ pub trait CharacterSet: Sized {
fn intersection<Other: CharacterSet>(
self,
other: Other,
) -> CharacterSetIntersection<Self, Other> {
) -> CharacterSetIntersection<Self, Other>
where
Self: Sized,
{
CharacterSetIntersection {
first: self,
second: other,
}
}

fn difference<Other: CharacterSet>(self, other: Other) -> CharacterSetDifference<Self, Other> {
fn difference<Other: CharacterSet>(self, other: Other) -> CharacterSetDifference<Self, Other>
where
Self: Sized,
{
CharacterSetDifference {
first: self,
second: other,
}
}

fn complement(self) -> CharacterSetComplement<Self> {
fn complement(self) -> CharacterSetComplement<Self>
where
Self: Sized,
{
CharacterSetComplement { inner: self }
}
}
Expand Down

0 comments on commit fb66891

Please sign in to comment.