impl WordSplitter for Box<T> where T: WordSplitter#254
impl WordSplitter for Box<T> where T: WordSplitter#254mgeisler merged 1 commit intomgeisler:masterfrom
Conversation
|
See https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/448 for a place where this is required and a workaround for the missing impl. |
|
Hi @sdroege, Thanks for plugging more holes in this. I tried testing with gst-plugin-textwrap and I cannot make it work. I looked at https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/448 and tried to adapt it to what I think you had in mind: modified text/wrap/src/gsttextwrap/imp.rs
@@ -95,18 +95,8 @@ impl Default for Settings {
}
}
-// FIXME: Not needed anymore after https://github.com/mgeisler/textwrap/pull/254
-#[derive(Debug)]
-struct Splitter(Box<dyn textwrap::WordSplitter + Send>);
-
-impl textwrap::WordSplitter for Splitter {
- fn split_points(&self, word: &str) -> Vec<usize> {
- self.0.split_points(word)
- }
-}
-
struct State {
- options: Option<textwrap::Options<'static, Splitter>>,
+ options: Option<textwrap::Options<'static, Box<dyn textwrap::WordSplitter>>>,
}
impl Default for State {
@@ -156,12 +146,12 @@ impl TextWrap {
Some(textwrap::Options::with_splitter(
settings.columns as usize,
- Splitter(Box::new(standard)),
+ Box::new(standard),
))
} else {
Some(textwrap::Options::with_splitter(
settings.columns as usize,
- Splitter(Box::new(textwrap::NoHyphenation)),
+ Box::new(textwrap::NoHyphenation),
))
};
}I then ran In both cases, I kept this error: I probably just misunderstood how to remove the Though I'm a bit perplexed by the sheer number of implementations needed, I'm happy to merge this if you've tested it and gotten it to work on your side? |
This is what is needed in both cases |
Ah, right you are! As you wrote, the uncommented and more general implementation by @Cryptjar also seems to work. So can i get you to change this PR to use that instead? I didn't fully understand the difference of the implementations back when #215 was merged and it seems we now have a great use case for the code. So it would be nice to use it :-) |
This allows more generic use, and e.g. as Box<dyn WordSplitter + Send>.
|
Excellent, thanks! |
|
Thanks, I'll update the GStreamer code once you've uploaded a new release to crates.io |
|
The new release has been made! 🎉 |
No description provided.