Skip to content

Commit

Permalink
impl From &[u8] for Str and Subsequence
Browse files Browse the repository at this point in the history
  • Loading branch information
jfolz committed Jul 25, 2024
1 parent a0936e9 commit a69b07a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/automaton/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ impl<'a> Str<'a> {
}
}

impl<'a> From<&'a [u8]> for Str<'a> {
fn from(string: &'a [u8]) -> Str<'a> {
Str { string }
}
}

impl<'a> Automaton for Str<'a> {
type State = Option<usize>;

Expand Down Expand Up @@ -251,6 +257,12 @@ impl<'a> Subsequence<'a> {
}
}

impl<'a> From<&'a [u8]> for Subsequence<'a> {
fn from(subsequence: &'a [u8]) -> Subsequence<'a> {
Subsequence { subseq: subsequence }
}
}

impl<'a> Automaton for Subsequence<'a> {
type State = usize;

Expand Down

0 comments on commit a69b07a

Please sign in to comment.