Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Dec 5, 2024
1 parent b9bce71 commit 3184fb2
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 38 deletions.
48 changes: 13 additions & 35 deletions c-api/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions c-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::missing_safety_doc)]

pub use crate::streaming::CStreamingHandler;
use libc::{c_char, c_int, c_void, size_t};
use lol_html::html_content::*;
Expand Down
3 changes: 3 additions & 0 deletions c-api/src/rewriter_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct ExternDocumentContentHandlers {
}

impl ExternDocumentContentHandlers {
#[must_use]
pub fn as_safe_document_content_handlers(&self) -> DocumentContentHandlers {
let mut handlers = DocumentContentHandlers::default();

Expand All @@ -77,6 +78,7 @@ pub struct ExternElementContentHandlers {
}

impl ExternElementContentHandlers {
#[must_use]
pub fn as_safe_element_content_handlers(&self) -> ElementContentHandlers {
let mut handlers = ElementContentHandlers::default();

Expand All @@ -100,6 +102,7 @@ pub struct HtmlRewriterBuilder {
}

impl HtmlRewriterBuilder {
#[must_use]
pub fn get_safe_handlers(&self) -> SafeContentHandlers {
SafeContentHandlers {
document: self
Expand Down
1 change: 1 addition & 0 deletions c-api/src/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub unsafe extern "C" fn lol_html_streaming_sink_write_utf8_chunk(
}

/// Safety: the user data and the callbacks must be safe to use from a different thread (e.g. can't rely on thread-local storage).
///
/// It doesn't have to be `Sync`, it will be used only by one thread at a time.
///
/// Handler functions copy this struct. It can (and should) be created on the stack.
Expand Down
2 changes: 1 addition & 1 deletion c-api/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Str {

impl Drop for Str {
fn drop(&mut self) {
if self.data == ptr::null() {
if self.data.is_null() {
return;
}
let bytes = unsafe { slice::from_raw_parts_mut(self.data.cast_mut(), self.len) };
Expand Down
4 changes: 2 additions & 2 deletions js-api/src/html_rewriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ pub struct HTMLRewriter(RewriterState);
#[wasm_bindgen]
impl HTMLRewriter {
#[wasm_bindgen(constructor)]
pub fn new(encoding: String, output_sink: &JsFunction) -> JsResult<HTMLRewriter> {
pub fn new(encoding: String, output_sink: &JsFunction) -> JsResult<Self> {
let encoding = Encoding::for_label(encoding.as_bytes())
.and_then(AsciiCompatibleEncoding::new)
.ok_or_else(|| JsError::new("Invalid encoding"))?;

Ok(HTMLRewriter(RewriterState::Before {
Ok(Self(RewriterState::Before {
output_sink: JsOutputSink::new(output_sink),
settings: Settings {
encoding,
Expand Down

0 comments on commit 3184fb2

Please sign in to comment.