I have a clippy suggestion ( here Font is a trait ):
---------- Clippy ----------
Checking pdf-min v0.1.1 (C:\rust\pdf-min)
warning: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> src\page.rs:65:34
|
65 | pub fn text(&mut self, font: &Box<dyn Font>, size: i16, s: &str) {
| ^^^^^^^^^^^^^^ help: try: `&dyn Font`
|
= note: `#[warn(clippy::borrowed_box)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#borrowed_box
warning: `pdf-min` (lib) generated 1 warning
Finished dev [unoptimized + debuginfo] target(s) in 0.37s
Normal Termination
Output completed (0 sec consumed).
Source is here: Page in pdf_min::page - Rust
The trouble is, when I change it as suggested I get compilation errors:
---------- Check ----------
Checking pdf-min v0.1.1 (C:\rust\pdf-min)
error[E0277]: the trait bound `Box<dyn font::Font>: font::Font` is not satisfied
--> src\writer.rs:117:21
|
117 | self.p.text(f, self.font_size, s);
| ^ the trait `font::Font` is not implemented for `Box<dyn font::Font>`
|
= help: the trait `font::Font` is implemented for `font::StandardFont`
= note: required for the cast to the object type `dyn font::Font`
error[E0277]: the trait bound `Box<(dyn font::Font + 'static)>: font::Font` is not satisfied
--> src\writer.rs:167:17
|
167 | &self.fonts[0],
| ^^^^^^^^^^^^^^ the trait `font::Font` is not implemented for `Box<(dyn font::Font + 'static)>`
|
= help: the trait `font::Font` is implemented for `font::StandardFont`
= note: required for the cast to the object type `dyn font::Font`
For more information about this error, try `rustc --explain E0277`.
error: could not compile `pdf-min` due to 2 previous errors
Normal Termination
Output completed (0 sec consumed).
I cannot figure out how to keep Clippy happy!