Skip to content

Commit

Permalink
impl WordSplitter for Box<dyn WordSplitter + Send> and for Send + Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
sdroege committed Dec 11, 2020
1 parent 45dc705 commit b9cca9e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/splitting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ impl WordSplitter for Box<dyn WordSplitter> {
self.deref().split_points(word)
}
}

impl WordSplitter for Box<dyn WordSplitter + Send> {
fn split_points(&self, word: &str) -> Vec<usize> {
use std::ops::Deref;
self.deref().split_points(word)
}
}

impl WordSplitter for Box<dyn WordSplitter + Send + Sync> {
fn split_points(&self, word: &str) -> Vec<usize> {
use std::ops::Deref;
self.deref().split_points(word)
}
}

/* Alternative, also adds impls for specific Box<S> i.e. Box<HyphenSplitter>
impl<S: WordSplitter + ?Sized> WordSplitter for Box<S> {
fn split<'w>(&self, word: &'w str) -> Vec<(&'w str, &'w str, &'w str)> {
Expand Down

0 comments on commit b9cca9e

Please sign in to comment.