Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Span {
- pub begin: usize,
- pub end: usize,
- }
- fn main() {
- let text = "the quick brown óf fox óf the end óf the world";
- let textstop = "óf the and of";
- let stopwords: Vec<_> = textstop.split_whitespace().collect();
- let mut spans: Vec<Span> = Vec::new();
- for word in &stopwords {
- let indexes: Vec<_> = text.match_indices(word).collect();
- let size = word.as_bytes().len();
- for (i, _) in &indexes {
- spans.push(Span {
- begin: *i,
- end: (*i + size),
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement