Skip to content

Commit

Permalink
Fix most clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Jun 18, 2024
1 parent b713ff7 commit e150874
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
6 changes: 3 additions & 3 deletions packages/dioxus-blitz/src/documents/dioxus_document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ impl AsMut<Document> for DioxusDocument {
&mut self.inner
}
}
impl Into<Document> for DioxusDocument {
fn into(self) -> Document {
self.inner
impl From<DioxusDocument> for Document {
fn from(doc: DioxusDocument) -> Document {
doc.inner
}
}
impl DocumentLike for DioxusDocument {
Expand Down
6 changes: 3 additions & 3 deletions packages/dioxus-blitz/src/documents/html_document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ impl AsMut<Document> for HtmlDocument {
&mut self.inner
}
}
impl Into<Document> for HtmlDocument {
fn into(self) -> Document {
self.inner
impl From<HtmlDocument> for Document {
fn from(doc: HtmlDocument) -> Document {
doc.inner
}
}
impl DocumentLike for HtmlDocument {}
Expand Down
3 changes: 1 addition & 2 deletions packages/dom/src/htmlsink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,7 @@ impl<'b> TreeSink for DocumentHtmlParser<'b> {
if has_appended {
return;
} else {
let id = self.create_text_node(&text);
id
self.create_text_node(&text)
}
}
NodeOrText::AppendNode(id) => id,
Expand Down
3 changes: 1 addition & 2 deletions packages/dom/src/stylo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,8 +815,7 @@ impl<'a> TElement for BlitzNode<'a> {
let root_element = TDocument::as_node(&root_node)
.first_element_child()
.unwrap();
let is_child_of_root_element = root_element.children.contains(&self.id);
is_child_of_root_element
root_element.children.contains(&self.id)
}

fn synthesize_presentational_hints_for_legacy_attributes<V>(
Expand Down
18 changes: 11 additions & 7 deletions packages/dom/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ use image::DynamicImage;
const USER_AGENT: &str = "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0";
const FILE_SIZE_LIMIT: u64 = 1_000_000_000; // 1GB

pub(crate) fn fetch_blob(url: &str) -> Result<Vec<u8>, ureq::Error> {
pub(crate) fn fetch_blob(url: &str) -> Result<Vec<u8>, Box<ureq::Error>> {
if url.starts_with("data:") {
let data_url = data_url::DataUrl::process(url).unwrap();
let decoded = data_url.decode_to_vec().expect("Invalid data url");
return Ok(decoded.0);
}

let resp = ureq::get(url).set("User-Agent", USER_AGENT).call()?;
let resp = ureq::get(url)
.set("User-Agent", USER_AGENT)
.call()
.map_err(Box::new)?;

let len: usize = resp
.header("Content-Length")
Expand All @@ -23,12 +26,13 @@ pub(crate) fn fetch_blob(url: &str) -> Result<Vec<u8>, ureq::Error> {

resp.into_reader()
.take(FILE_SIZE_LIMIT)
.read_to_end(&mut bytes)?;
.read_to_end(&mut bytes)
.unwrap();

Ok(bytes)
}

pub(crate) fn fetch_string(url: &str) -> Result<String, ureq::Error> {
pub(crate) fn fetch_string(url: &str) -> Result<String, Box<ureq::Error>> {
fetch_blob(url).map(|vec| String::from_utf8(vec).expect("Invalid UTF8"))
}

Expand All @@ -41,11 +45,11 @@ pub(crate) fn fetch_string(url: &str) -> Result<String, ureq::Error> {

#[allow(unused)]
pub(crate) enum ImageFetchErr {
FetchErr(ureq::Error),
FetchErr(Box<ureq::Error>),
ImageError(image::error::ImageError),
}
impl From<ureq::Error> for ImageFetchErr {
fn from(value: ureq::Error) -> Self {
impl From<Box<ureq::Error>> for ImageFetchErr {
fn from(value: Box<ureq::Error>) -> Self {
Self::FetchErr(value)
}
}
Expand Down

0 comments on commit e150874

Please sign in to comment.