Skip to content

Commit

Permalink
Renaming AsPdfLine to ToPdfLine to make clippy happy.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmadrid committed Jan 5, 2023
1 parent 45ce811 commit f138c2c
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions src/bin/active.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use printpdf::*;
use weekly::{
save_one_page_document, AsPdfLine, Attributes, GridDescription, Instructions, NumericUnit,
save_one_page_document, ToPdfLine, Attributes, GridDescription, Instructions, NumericUnit,
TGrid, Unit, WRect,
};

Expand Down Expand Up @@ -51,7 +51,7 @@ impl GridDescription for ActiveDescription {
cell_rect.left() + self.task_height / 4,
cell_rect.top() - self.task_height / 4,
);
let mut shape = check_rect.as_pdf_line();
let mut shape = check_rect.to_pdf_line();
shape.has_fill = false;
shape.has_stroke = true;
instructions.push_shape(shape);
Expand Down
6 changes: 3 additions & 3 deletions src/bin/cornell.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use printpdf::PdfDocumentReference;
use weekly::{
save_one_page_document, AsPdfLine, Attributes, Colors, GridDescription, Instructions, TGrid,
save_one_page_document, ToPdfLine, Attributes, Colors, GridDescription, Instructions, TGrid,
Unit, WLine, WRect,
};

Expand Down Expand Up @@ -75,12 +75,12 @@ fn render_cornell(_: &PdfDocumentReference, device_rect: &WRect) -> weekly::Resu
device_rect.right(),
bottom_line_y,
);
instructions.push_shape(notes_bottom_line.as_pdf_line());
instructions.push_shape(notes_bottom_line.to_pdf_line());

let left_line_x = device_rect.width().pct(100.0 - NOTE_HORIZ_PCT);

let notes_left_line = WLine::line(left_line_x, bottom_line_y, left_line_x, device_rect.top());
instructions.push_shape(notes_left_line.as_pdf_line());
instructions.push_shape(notes_left_line.to_pdf_line());

let grid_rect = WRect::with_dimensions(
device_rect.right() - left_line_x,
Expand Down
6 changes: 3 additions & 3 deletions src/bin/daily.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use printpdf::{Color, PdfDocumentReference};
use std::borrow::Cow;
use std::path::PathBuf;
use weekly::{
save_one_page_document, sizes, AsPdfLine, Attributes, Colors, Datetools, LineModifiers,
save_one_page_document, sizes, ToPdfLine, Attributes, Colors, Datetools, LineModifiers,
NumericUnit, Result, TGrid, Unit, WRect,
};
use weekly::{GridDescription, Instructions};
Expand Down Expand Up @@ -252,7 +252,7 @@ impl GridDescription for DailyDescription {
let date = &self.dates_in_month[row];
if !day_set.contains(&date.weekday()) {
instructions.set_fill_color(Colors::gray(0.7));
instructions.push_shape(cell_rect.as_pdf_line());
instructions.push_shape(cell_rect.to_pdf_line());
should_draw_checkbox = false;
}
}
Expand All @@ -277,7 +277,7 @@ fn render_checkbox(cell_rect: &WRect, instructions: &mut Instructions) {
instructions.set_stroke_color(Colors::gray(0.25));
instructions.set_stroke_width(0.0);

instructions.push_shape(checkbox_rect.as_pdf_line().fill(false).stroke(true));
instructions.push_shape(checkbox_rect.to_pdf_line().fill(false).stroke(true));
}

fn render_dailies(
Expand Down
6 changes: 3 additions & 3 deletions src/bin/projects.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use printpdf::PdfDocumentReference;
use weekly::{
save_one_page_document, AsPdfLine, Colors, Instructions, LineModifiers, NumericUnit, Unit,
save_one_page_document, ToPdfLine, Colors, Instructions, LineModifiers, NumericUnit, Unit,
WLine, WRect,
};

Expand Down Expand Up @@ -63,7 +63,7 @@ fn fill_project_into_rect(rect: WRect, instructions: &mut Instructions) {
rect.right(),
rect.top() - 0.25.inches(),
)
.as_pdf_line(),
.to_pdf_line(),
);

instructions.set_stroke_color(Colors::gray(0.75));
Expand All @@ -80,7 +80,7 @@ fn fill_box_with_lines(boxx: &WRect, offset: Unit, gap: Unit, instructions: &mut

while curr_y > boxx.bottom_q1() {
let line = WLine::line(boxx.left(), curr_y, boxx.right(), curr_y);
instructions.push_shape(line.as_pdf_line());
instructions.push_shape(line.to_pdf_line());
curr_y = curr_y - gap;
}
}
4 changes: 2 additions & 2 deletions src/bin/remtest.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use printpdf::PdfDocumentReference;
use weekly::{
save_one_page_document, AsPdfLine, Colors, Instructions, LineModifiers, NumericUnit, WRect,
save_one_page_document, ToPdfLine, Colors, Instructions, LineModifiers, NumericUnit, WRect,
};

const REMARKABLE_WIDTH: f64 = 157.2;
Expand All @@ -13,7 +13,7 @@ fn render_remtest(_: &PdfDocumentReference, page_bounds: &WRect) -> weekly::Resu
instructions.set_stroke_color(Colors::black());

let black_rect = dbg!(page_bounds.inset_q1(2.0.mm(), 2.0.mm()));
let rect_shape = black_rect.as_pdf_line().fill(false).stroke(true);
let rect_shape = black_rect.to_pdf_line().fill(false).stroke(true);
instructions.push_shape(rect_shape);

Ok(instructions)
Expand Down
8 changes: 4 additions & 4 deletions src/bin/weekly.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use argh::FromArgs;
use printpdf::PdfDocumentReference;
use weekly::{
save_one_page_document, sizes, AsPdfLine, Attributes, Circle, Colors, FontProxy,
save_one_page_document, sizes, ToPdfLine, Attributes, Circle, Colors, FontProxy,
GridDescription, Instructions, LineModifiers, NumericUnit, Result, TGrid, Unit, WLine, WRect,
};

Expand Down Expand Up @@ -134,7 +134,7 @@ fn render_lines<T: AsRef<str>, F: Fn(&WRect, usize, &mut Instructions)>(
.set_offset(offset);
let tgrid = TGrid::with_description(description);

instructions.push_shape(table_rect.as_pdf_line().fill(false).stroke(true));
instructions.push_shape(table_rect.to_pdf_line().fill(false).stroke(true));

tgrid.append_to_instructions(&mut instructions);

Expand Down Expand Up @@ -175,7 +175,7 @@ fn render_days(rect: &WRect) -> Result<Instructions> {
rect.left() + radius + 2.0.mm(),
rect.bottom_q1() + radius / 2.0 + 0.8.mm(),
)
.as_pdf_line()
.to_pdf_line()
.fill(true),
);
instructions.pop_state();
Expand Down Expand Up @@ -319,7 +319,7 @@ fn render_dotted(_: &PdfDocumentReference, dotted_rect: &WRect) -> Result<Instru
instructions.push_shape(
base_circle
.move_to(x, y)
.as_pdf_line()
.to_pdf_line()
.fill(true)
.stroke(false),
);
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub use pdfutils::{
pub use shapes::circle::Circle;
pub use shapes::line::WLine;
pub use shapes::rect::WRect;
pub use shapes::AsPdfLine;
pub use shapes::ToPdfLine;
pub use tgrid::description::GridDescription;
pub use tgrid::TGrid;
pub use units::{NumericUnit, Unit};
Expand Down
6 changes: 3 additions & 3 deletions src/pdfutils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::units::Unit;
use crate::{AsPdfLine, Result, WRect};
use crate::{ToPdfLine, Result, WRect};
use printpdf::*;
use std::collections::HashMap;
use std::fs::File;
Expand Down Expand Up @@ -37,9 +37,9 @@ impl Instructions {
self.instructions.push(Instruction::Translate(x, y));
}

pub fn push_shape(&mut self, shape: impl AsPdfLine) {
pub fn push_shape(&mut self, shape: impl ToPdfLine) {
self.instructions
.push(Instruction::Shape(shape.as_pdf_line()))
.push(Instruction::Shape(shape.to_pdf_line()))
}

pub fn push_text(&mut self, s: &str, text_height: f64, x: Unit, y: Unit, font: FontProxy) {
Expand Down
6 changes: 3 additions & 3 deletions src/shapes/circle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{AsPdfLine, NumericUnit, Unit};
use crate::{ToPdfLine, NumericUnit, Unit};
use printpdf::Line;

#[derive(Debug)]
Expand Down Expand Up @@ -34,8 +34,8 @@ impl Circle {
}
}

impl AsPdfLine for Circle {
fn as_pdf_line(self) -> Line {
impl ToPdfLine for Circle {
fn to_pdf_line(self) -> Line {
let points = printpdf::calculate_points_for_circle(self.radius, self.x, self.y);
Line {
points,
Expand Down
6 changes: 3 additions & 3 deletions src/shapes/line.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::pdfutils::point_pair;
use crate::shapes::AsPdfLine;
use crate::shapes::ToPdfLine;
use crate::units::Unit;
use printpdf::Line;

Expand All @@ -17,8 +17,8 @@ impl WLine {
}
}

impl AsPdfLine for WLine {
fn as_pdf_line(self) -> Line {
impl ToPdfLine for WLine {
fn to_pdf_line(self) -> Line {
Line {
points: vec![
point_pair(self.x1, self.y1, false),
Expand Down
8 changes: 4 additions & 4 deletions src/shapes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ pub(crate) mod circle;
pub(crate) mod line;
pub(crate) mod rect;

pub trait AsPdfLine {
fn as_pdf_line(self) -> Line;
pub trait ToPdfLine {
fn to_pdf_line(self) -> Line;
}

impl AsPdfLine for Line {
fn as_pdf_line(self) -> Line {
impl ToPdfLine for Line {
fn to_pdf_line(self) -> Line {
self
}
}
12 changes: 6 additions & 6 deletions src/shapes/rect.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::pdfutils::point_pair;
use crate::shapes::AsPdfLine;
use crate::shapes::ToPdfLine;
use crate::units::Unit;
use printpdf::*;

Expand Down Expand Up @@ -124,14 +124,14 @@ impl WRect {
}
}

impl AsPdfLine for WRect {
fn as_pdf_line(self) -> Line {
(&self).as_pdf_line()
impl ToPdfLine for WRect {
fn to_pdf_line(self) -> Line {
(&self).to_pdf_line()
}
}

impl AsPdfLine for &WRect {
fn as_pdf_line(self) -> Line {
impl ToPdfLine for &WRect {
fn to_pdf_line(self) -> Line {
Line {
// In Q1, rects grow downward toward the bottom.
points: vec![
Expand Down
8 changes: 4 additions & 4 deletions src/tgrid/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::tgrid::renderparams::RenderParams;
use crate::{AsPdfLine, Colors, Instructions, NumericUnit, Unit, WLine, WRect};
use crate::{ToPdfLine, Colors, Instructions, NumericUnit, Unit, WLine, WRect};
use description::GridDescription;

pub mod description;
Expand Down Expand Up @@ -33,7 +33,7 @@ where
if let Some(attrs) = self.params.horiz_line_style(row, num_rows) {
attrs.render(instructions, |instructions| {
let y = top - self.params.row_height * row as f64;
instructions.push_shape(WLine::line(left, y, right, y).as_pdf_line());
instructions.push_shape(WLine::line(left, y, right, y).to_pdf_line());
});
}
}
Expand All @@ -50,7 +50,7 @@ where
if let Some(attrs) = self.params.vert_line_style(col, num_cols) {
attrs.render(instructions, |instructions| {
let x = left + self.params.col_width * col as f64;
instructions.push_shape(WLine::line(x, top, x, bottom).as_pdf_line())
instructions.push_shape(WLine::line(x, top, x, bottom).to_pdf_line())
});
}
}
Expand Down Expand Up @@ -129,7 +129,7 @@ where
let x = self.col_x(col);
let rect = base_col_rect.move_to(x, self.params.grid_bounds.top());
instructions.set_fill_color(color);
instructions.push_shape(rect.as_pdf_line());
instructions.push_shape(rect.to_pdf_line());
}
}
}
Expand Down

0 comments on commit f138c2c

Please sign in to comment.