Skip to content

Commit 643fc73

Browse files
Minor: Resolved this warning associated with a "Non-Standard" default() method.
When I looked at the warning, I noted that everything could be auto derived. ``` warning: method `default` can be confused for the standard trait method `std::default::Default::default` --> plotters-backend/src/text.rs:120:9 | 120 | / pub fn default() -> Self { 121 | | Pos { 122 | | h_pos: HPos::Left, 123 | | v_pos: VPos::Top, 124 | | } 125 | | } | |_________^ | = help: consider implementing the trait `std::default::Default` or choosing a less ambiguous method name = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#should_implement_trait = note: `#[warn(clippy::should_implement_trait)]` on by default ```
1 parent 7c4ed88 commit 643fc73

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

plotters-backend/src/text.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ impl<'a> From<&'a str> for FontFamily<'a> {
6060
/// ```
6161
pub mod text_anchor {
6262
/// The horizontal position of the anchor point relative to the text.
63-
#[derive(Clone, Copy)]
63+
#[derive(Clone, Copy, Default)]
6464
pub enum HPos {
6565
/// Anchor point is on the left side of the text
66+
#[default]
6667
Left,
6768
/// Anchor point is on the right side of the text
6869
Right,
@@ -71,9 +72,10 @@ pub mod text_anchor {
7172
}
7273

7374
/// The vertical position of the anchor point relative to the text.
74-
#[derive(Clone, Copy)]
75+
#[derive(Clone, Copy, Default)]
7576
pub enum VPos {
7677
/// Anchor point is on the top of the text
78+
#[default]
7779
Top,
7880
/// Anchor point is in the vertical center of the text
7981
Center,
@@ -82,7 +84,7 @@ pub mod text_anchor {
8284
}
8385

8486
/// The text anchor position.
85-
#[derive(Clone, Copy)]
87+
#[derive(Clone, Copy, Default)]
8688
pub struct Pos {
8789
/// The horizontal position of the anchor point
8890
pub h_pos: HPos,
@@ -106,21 +108,6 @@ pub mod text_anchor {
106108
Pos { h_pos, v_pos }
107109
}
108110

109-
/// Create a default text anchor position (top left).
110-
///
111-
/// - **returns** The default text anchor position
112-
///
113-
/// ```rust
114-
/// use plotters_backend::text_anchor::{Pos, HPos, VPos};
115-
///
116-
/// let pos = Pos::default();
117-
/// ```
118-
pub fn default() -> Self {
119-
Pos {
120-
h_pos: HPos::Left,
121-
v_pos: VPos::Top,
122-
}
123-
}
124111
}
125112
}
126113

0 commit comments

Comments
 (0)