Skip to content

Commit

Permalink
obey lord clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
soupslurpr committed Dec 7, 2023
1 parent d6452f4 commit 75e1f01
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 25 deletions.
5 changes: 3 additions & 2 deletions beautyxt_rs/src/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ pub fn markdown_to_docx(markdown: String) -> Vec<u8> {
let font_size = if style.contains(font_size_css) {
let index = style.find(font_size_css).unwrap();

let remaining = &style[index + &font_size_css.len()..].trim();
let remaining = &style[index + font_size_css.len()..].trim();

let fontsize = remaining
.split(|c: char| !c.is_numeric())
Expand All @@ -221,6 +221,7 @@ pub fn markdown_to_docx(markdown: String) -> Vec<u8> {
11
};

#[allow(clippy::single_match)]
match element.value().name.local.as_ref() {
"div" => {
for child in node.children() {
Expand Down Expand Up @@ -274,7 +275,7 @@ pub fn markdown_to_docx(markdown: String) -> Vec<u8> {
*run = Some(
run_ref
.clone()
.add_text(node.to_string().replace("\n", " ")),
.add_text(node.to_string().replace('\n', " ")),
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion beautyxt_rs/src/plain_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::io::Cursor;
pub fn plain_text_to_docx(plain_text: String) -> Vec<u8> {
let mut docx = Docx::new();

for paragraph in plain_text.split("\n") {
for paragraph in plain_text.split('\n') {
docx = docx.add_paragraph(docx_rs::Paragraph::new().add_run(Run::new().add_text(paragraph)))
}

Expand Down
32 changes: 10 additions & 22 deletions beautyxt_rs/src/typst.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
use typst::text::Font;
use typst::text::FontBook;
use typst::Library;
use typst::layout::Abs;
use chrono::{Datelike, FixedOffset, Local, TimeZone, Timelike, Utc};
use comemo::Prehashed;
use once_cell::sync::Lazy;
use typst_svg::svg;
#[cfg(target_family = "unix")]
use std::os::fd::FromRawFd;
use std::{
fs::File,
io::{Read, Seek, Write},
sync::Mutex,
};
use typst::layout::Abs;
use typst::text::Font;
use typst::text::FontBook;
use typst::Library;
use typst::{diag::EcoString, foundations::Bytes};
use typst::{
diag::{FileError, FileResult, Severity, Tracepoint},
Expand Down Expand Up @@ -47,15 +46,7 @@ pub struct ProjectFilePathAndFile {
}

impl ProjectFilePathAndFile {
pub fn new(path: String, file: File) -> Self {
ProjectFilePathAndFile {
path,
file,
source: None,
bytes: None,
}
}

#[allow(unreachable_code)]
pub fn from_project_file_path_and_fd(project_file_path_and_fd: &ProjectFilePathAndFd) -> Self {
ProjectFilePathAndFile {
path: project_file_path_and_fd.path.clone(),
Expand Down Expand Up @@ -293,9 +284,7 @@ pub fn test_get_main_pdf() -> Vec<u8> {

let document = typst::compile(world, &mut tracer).unwrap();

let pdf = typst_pdf::pdf(&document, None, None);

pdf
typst_pdf::pdf(&document, None, None)
}

/// The severity of a [`SourceDiagnostic`].
Expand Down Expand Up @@ -385,10 +374,9 @@ pub fn test_get_main_svg() -> Result<Vec<u8>, RenderError> {
match &spanned.v {
Tracepoint::Call(function_call) => CustomTracepoint::Call {
span,
string: match function_call {
Some(eco_string) => Some(eco_string.to_string()),
None => None,
},
string: function_call
.as_ref()
.map(|eco_string| eco_string.to_string()),
},
Tracepoint::Show(show_rule_application) => CustomTracepoint::Show {
string: show_rule_application.to_string(),
Expand Down Expand Up @@ -671,7 +659,7 @@ impl World for SomeWorld {
let local_time = fixed_offset.from_utc_datetime(&now.naive_utc());

Some(Datetime::from_ymd_hms(
local_time.year().try_into().ok()?,
local_time.year(),
local_time.month().try_into().ok()?,
local_time.day().try_into().ok()?,
local_time.hour().try_into().ok()?,
Expand Down

0 comments on commit 75e1f01

Please sign in to comment.