generated from ElnuDev/rust-project
cargo fmt
This commit is contained in:
parent
0ad5b4df3b
commit
7c27f869c9
4 changed files with 30 additions and 23 deletions
|
@ -1,9 +1,9 @@
|
||||||
pub mod svg;
|
pub mod svg;
|
||||||
use svg::*;
|
use svg::*;
|
||||||
|
|
||||||
use std::{fs::OpenOptions, io::Write};
|
|
||||||
use askama::Template;
|
use askama::Template;
|
||||||
use derive_more::From;
|
use derive_more::From;
|
||||||
|
use std::{fs::OpenOptions, io::Write};
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "document.xml")]
|
#[template(path = "document.xml")]
|
||||||
|
@ -26,7 +26,7 @@ fn main() -> Result<(), Error> {
|
||||||
.open("output.svg")?;
|
.open("output.svg")?;
|
||||||
let document = DocumentTemplate {
|
let document = DocumentTemplate {
|
||||||
width: SVGMeasure::new(8.5, SVGUnit::Inch),
|
width: SVGMeasure::new(8.5, SVGUnit::Inch),
|
||||||
height: SVGMeasure::new(11.0,SVGUnit::Inch),
|
height: SVGMeasure::new(11.0, SVGUnit::Inch),
|
||||||
};
|
};
|
||||||
write!(file, "{}", document.render()?)?;
|
write!(file, "{}", document.render()?)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
use super::SVGUnit;
|
use super::SVGUnit;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::{ops::{Add, Sub, Mul, Div}, fmt::Display};
|
use std::{
|
||||||
|
fmt::Display,
|
||||||
|
ops::{Add, Div, Mul, Sub},
|
||||||
|
};
|
||||||
|
|
||||||
pub struct SVGMeasure {
|
pub struct SVGMeasure {
|
||||||
pub measure: f64,
|
pub measure: f64,
|
||||||
|
|
|
@ -35,7 +35,10 @@ pub enum SVGUnit {
|
||||||
impl Display for SVGUnit {
|
impl Display for SVGUnit {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
use SVGUnit::*;
|
use SVGUnit::*;
|
||||||
write!(f, "{}", match &self {
|
write!(
|
||||||
|
f,
|
||||||
|
"{}",
|
||||||
|
match &self {
|
||||||
Pixel => "px",
|
Pixel => "px",
|
||||||
Inch => "in",
|
Inch => "in",
|
||||||
Centimeter => "cm",
|
Centimeter => "cm",
|
||||||
|
@ -50,6 +53,7 @@ impl Display for SVGUnit {
|
||||||
ViewportHeight => "vh",
|
ViewportHeight => "vh",
|
||||||
ViewportMinimum => "vmin",
|
ViewportMinimum => "vmin",
|
||||||
ViewportMaximum => "vmax",
|
ViewportMaximum => "vmax",
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue