Skip to content

Commit 154f2bb

Browse files
authored
Merge pull request #123 from embedded-graphics/clippy
Clean up
2 parents da8394b + ac6a4ee commit 154f2bb

10 files changed

Lines changed: 14 additions & 40 deletions

File tree

src/alignment/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl HorizontalAlignment {
3939
}
4040

4141
/// Calculate offset from the left side and whitespace information.
42-
pub fn place_line(
42+
pub(crate) fn place_line(
4343
self,
4444
line: &str,
4545
renderer: &impl TextRenderer,
@@ -113,10 +113,10 @@ pub enum VerticalAlignment {
113113

114114
impl VerticalAlignment {
115115
/// Set the cursor's initial vertical position
116-
pub fn apply_vertical_alignment<'a, 'b, S>(
116+
pub(crate) fn apply_vertical_alignment<'a, S>(
117117
self,
118118
cursor: &mut Cursor,
119-
styled_text_box: &'b TextBox<'a, S>,
119+
styled_text_box: &TextBox<'a, S>,
120120
) where
121121
S: TextRenderer,
122122
{

src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ use embedded_graphics::{
140140
/// [module-level documentation]: index.html
141141
/// [`draw`]: #method.draw
142142
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
143+
#[must_use]
143144
pub struct TextBox<'a, S> {
144145
/// The text to be displayed in this `TextBox`
145146
pub text: &'a str,
@@ -163,7 +164,6 @@ where
163164
{
164165
/// Creates a new `TextBox` instance with a given bounding `Rectangle`.
165166
#[inline]
166-
#[must_use]
167167
pub fn new(text: &'a str, bounds: Rectangle, character_style: S) -> Self {
168168
TextBox::with_textbox_style(text, bounds, character_style, TextBoxStyle::default())
169169
}
@@ -175,7 +175,6 @@ where
175175
{
176176
/// Creates a new `TextBox` instance with a given bounding `Rectangle` and a given `TextBoxStyle`.
177177
#[inline]
178-
#[must_use]
179178
pub fn with_textbox_style(
180179
text: &'a str,
181180
bounds: Rectangle,
@@ -197,7 +196,6 @@ where
197196

198197
/// Creates a new `TextBox` instance with a given bounding `Rectangle` and a given `TextBoxStyle`.
199198
#[inline]
200-
#[must_use]
201199
pub fn with_alignment(
202200
text: &'a str,
203201
bounds: Rectangle,
@@ -214,7 +212,6 @@ where
214212

215213
/// Creates a new `TextBox` instance with a given bounding `Rectangle` and a given `TextBoxStyle`.
216214
#[inline]
217-
#[must_use]
218215
pub fn with_vertical_alignment(
219216
text: &'a str,
220217
bounds: Rectangle,
@@ -242,7 +239,6 @@ where
242239
Self: Clone,
243240
{
244241
#[inline]
245-
#[must_use]
246242
fn translate(&self, by: Point) -> Self {
247243
Self {
248244
bounds: self.bounds.translate(by),
@@ -260,7 +256,6 @@ where
260256

261257
impl<S> Dimensions for TextBox<'_, S> {
262258
#[inline]
263-
#[must_use]
264259
fn bounding_box(&self) -> Rectangle {
265260
self.bounds
266261
}

src/parser/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ impl<'a> Parser<'a> {
7676
/// Create a new parser object to process the given piece of text.
7777
#[inline]
7878
#[must_use]
79+
7980
pub fn parse(text: &'a str) -> Self {
8081
Self {
8182
inner: text.chars(),

src/rendering/cursor.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,41 +28,27 @@ impl LineCursor {
2828
}
2929

3030
/// Returns the distance to the next tab position.
31-
#[inline]
3231
pub fn next_tab_width(&self) -> u32 {
3332
let next_tab_pos = (self.position / self.tab_width + 1) * self.tab_width;
3433
next_tab_pos - self.position
3534
}
3635

37-
/// Returns the width of the textbox
38-
#[inline]
39-
#[must_use]
36+
/// Returns the width of the text box.
4037
pub fn line_width(&self) -> u32 {
4138
self.width
4239
}
4340

44-
/// Moves the cursor back to the start of the line.
45-
#[inline]
46-
pub fn carriage_return(&mut self) {
47-
self.position = 0;
48-
}
49-
5041
/// Returns whether the current line has enough space to also include an object of given width.
51-
#[inline]
52-
#[must_use]
5342
pub fn fits_in_line(&self, width: u32) -> bool {
5443
width <= self.space()
5544
}
5645

5746
/// Returns the amount of empty space in the line.
58-
#[inline]
59-
#[must_use]
6047
pub fn space(&self) -> u32 {
6148
self.width - self.position
6249
}
6350

6451
/// Moves the cursor by a given amount.
65-
#[inline]
6652
pub fn move_cursor(&mut self, by: i32) -> Result<i32, i32> {
6753
if by < 0 {
6854
let abs = by.abs() as u32;
@@ -120,6 +106,7 @@ impl Cursor {
120106
}
121107
}
122108

109+
#[must_use]
123110
pub fn line(&self) -> LineCursor {
124111
LineCursor {
125112
start: Point::new(self.bounds.top_left.x, self.y),
@@ -143,14 +130,12 @@ impl Cursor {
143130

144131
/// Returns the width of the text box.
145132
#[inline]
146-
#[must_use]
147133
pub fn line_width(&self) -> u32 {
148134
self.bounds.size.width
149135
}
150136

151137
/// Returns the height of a line.
152138
#[inline]
153-
#[must_use]
154139
pub fn line_height(&self) -> i32 {
155140
self.line_height
156141
}

src/rendering/line.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ where
5959
<F as CharacterStyle>::Color: From<Rgb888>,
6060
{
6161
/// Creates a new line renderer.
62-
#[inline]
6362
pub fn new(cursor: LineCursor, state: LineRenderState<'a, F>) -> Self {
6463
Self { cursor, state }
6564
}

src/rendering/line_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use as_slice::AsSlice;
1919

2020
/// Parser to break down a line into primitive elements used by measurement and rendering.
2121
#[derive(Debug)]
22+
#[must_use]
2223
pub struct LineElementParser<'a, 'b> {
2324
/// Position information.
2425
cursor: LineCursor,
@@ -63,7 +64,6 @@ pub trait ElementHandler {
6364
impl<'a, 'b> LineElementParser<'a, 'b> {
6465
/// Creates a new element parser.
6566
#[inline]
66-
#[must_use]
6767
pub fn new(
6868
parser: &'b mut Parser<'a>,
6969
cursor: LineCursor,

src/style/builder.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use crate::{
1010
///
1111
/// [`TextBoxStyle`]: struct.TextBoxStyle.html
1212
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
13+
#[must_use]
1314
pub struct TextBoxStyleBuilder {
1415
style: TextBoxStyle,
1516
}
@@ -24,7 +25,6 @@ impl Default for TextBoxStyleBuilder {
2425
impl TextBoxStyleBuilder {
2526
/// Creates a new text box style builder object.
2627
#[inline]
27-
#[must_use]
2828
pub const fn new() -> Self {
2929
Self {
3030
style: TextBoxStyle {
@@ -54,7 +54,6 @@ impl TextBoxStyleBuilder {
5454
/// .build();
5555
/// ```
5656
#[inline]
57-
#[must_use]
5857
pub const fn line_height(mut self, line_height: LineHeight) -> Self {
5958
self.style.line_height = line_height;
6059

@@ -74,7 +73,6 @@ impl TextBoxStyleBuilder {
7473
/// .build();
7574
/// ```
7675
#[inline]
77-
#[must_use]
7876
pub const fn paragraph_spacing(mut self, paragraph_spacing: u32) -> Self {
7977
self.style.paragraph_spacing = paragraph_spacing;
8078

@@ -83,7 +81,6 @@ impl TextBoxStyleBuilder {
8381

8482
/// Sets the horizontal text alignment.
8583
#[inline]
86-
#[must_use]
8784
pub const fn alignment(mut self, alignment: HorizontalAlignment) -> TextBoxStyleBuilder {
8885
self.style.alignment = alignment;
8986

@@ -92,7 +89,6 @@ impl TextBoxStyleBuilder {
9289

9390
/// Sets the vertical text alignment.
9491
#[inline]
95-
#[must_use]
9692
pub const fn vertical_alignment(
9793
mut self,
9894
vertical_alignment: VerticalAlignment,
@@ -104,7 +100,6 @@ impl TextBoxStyleBuilder {
104100

105101
/// Sets the height mode.
106102
#[inline]
107-
#[must_use]
108103
pub const fn height_mode(mut self, height_mode: HeightMode) -> TextBoxStyleBuilder {
109104
self.style.height_mode = height_mode;
110105

@@ -113,7 +108,6 @@ impl TextBoxStyleBuilder {
113108

114109
/// Sets the tab size.
115110
#[inline]
116-
#[must_use]
117111
pub const fn tab_size(mut self, tab_size: TabSize) -> Self {
118112
self.style.tab_size = tab_size;
119113

@@ -124,7 +118,6 @@ impl TextBoxStyleBuilder {
124118
///
125119
/// [`TextBoxStyle`]: struct.TextBoxStyle.html
126120
#[inline]
127-
#[must_use]
128121
pub const fn build(self) -> TextBoxStyle {
129122
self.style
130123
}

src/style/height_mode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl HeightMode {
196196
/// Apply the height mode to the text box.
197197
///
198198
/// *Note:* This function normally does not need to be called manually.
199-
pub fn apply<F>(self, text_box: &mut TextBox<'_, F>)
199+
pub(crate) fn apply<F>(self, text_box: &mut TextBox<'_, F>)
200200
where
201201
F: TextRenderer,
202202
{
@@ -216,7 +216,7 @@ impl HeightMode {
216216
/// If a line does not fully fit in the bounding box, some `HeightMode` options allow drawing
217217
/// partial lines. For a partial line, this function calculates, which rows of each character
218218
/// should be displayed.
219-
pub fn calculate_displayed_row_range(self, cursor: &Cursor) -> Range<i32> {
219+
pub(crate) fn calculate_displayed_row_range(self, cursor: &Cursor) -> Range<i32> {
220220
let overdraw = match self {
221221
HeightMode::Exact(overdraw) | HeightMode::ShrinkToText(overdraw) => overdraw,
222222
HeightMode::FitToText => VerticalOverdraw::Visible,

src/style/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ impl TabSize {
207207
/// [`from_text_style`]: #method.from_text_style
208208
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
209209
#[non_exhaustive]
210+
#[must_use]
210211
pub struct TextBoxStyle {
211212
/// Horizontal text alignment.
212213
pub alignment: HorizontalAlignment,
@@ -252,6 +253,7 @@ impl Default for TextBoxStyle {
252253

253254
/// Information about a line.
254255
#[derive(Debug)]
256+
#[must_use]
255257
pub struct LineMeasurement {
256258
/// Maximum line width in pixels.
257259
pub max_line_width: u32,
@@ -306,7 +308,6 @@ impl TextBoxStyle {
306308
/// processing a token. If a token opens a new line, it will be returned as the carried token.
307309
/// If the carried token is `None`, the parser has finished processing the text.
308310
#[inline]
309-
#[must_use]
310311
pub(crate) fn measure_line<'a, S>(
311312
&self,
312313
character_style: &S,

src/style/vertical_overdraw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub enum VerticalOverdraw {
1515

1616
impl VerticalOverdraw {
1717
/// Calculate the range of rows of the current line that can be drawn.
18-
pub fn calculate_displayed_row_range(self, cursor: &Cursor) -> Range<i32> {
18+
pub(crate) fn calculate_displayed_row_range(self, cursor: &Cursor) -> Range<i32> {
1919
match self {
2020
VerticalOverdraw::FullRowsOnly => {
2121
if cursor.in_display_area() {

0 commit comments

Comments
 (0)