Clippy suggestions
This commit is contained in:
parent
766498ebfb
commit
28944e33a4
|
@ -150,7 +150,7 @@ impl AttrValMinified {
|
|||
self.prefix.len() + (self.data.len() - self.start) + self.suffix.len()
|
||||
}
|
||||
|
||||
pub fn out(&self, out: &mut Vec<u8>) -> () {
|
||||
pub fn out(&self, out: &mut Vec<u8>) {
|
||||
out.extend_from_slice(self.prefix);
|
||||
out.extend_from_slice(&self.data[self.start..]);
|
||||
out.extend_from_slice(self.suffix);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::cfg::Cfg;
|
||||
|
||||
pub fn minify_bang(cfg: &Cfg, out: &mut Vec<u8>, code: &[u8], ended: bool) -> () {
|
||||
pub fn minify_bang(cfg: &Cfg, out: &mut Vec<u8>, code: &[u8], ended: bool) {
|
||||
if !cfg.remove_bangs {
|
||||
out.extend_from_slice(b"<!");
|
||||
out.extend_from_slice(&code);
|
||||
out.extend_from_slice(code);
|
||||
if ended {
|
||||
out.extend_from_slice(b">");
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::cfg::Cfg;
|
||||
|
||||
pub fn minify_comment(cfg: &Cfg, out: &mut Vec<u8>, code: &[u8], ended: bool) -> () {
|
||||
pub fn minify_comment(cfg: &Cfg, out: &mut Vec<u8>, code: &[u8], ended: bool) {
|
||||
if !cfg.remove_comments {
|
||||
out.extend_from_slice(b"<!--");
|
||||
out.extend_from_slice(&code);
|
||||
out.extend_from_slice(code);
|
||||
if ended {
|
||||
out.extend_from_slice(b"-->");
|
||||
};
|
||||
|
|
|
@ -48,7 +48,7 @@ pub fn minify_content(
|
|||
// Use empty slice if none.
|
||||
parent: &[u8],
|
||||
mut nodes: Vec<NodeData>,
|
||||
) -> () {
|
||||
) {
|
||||
let &WhitespaceMinification {
|
||||
collapse,
|
||||
destroy_whole,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::cfg::Cfg;
|
||||
|
||||
pub fn minify_css(cfg: &Cfg, out: &mut Vec<u8>, code: &[u8]) -> () {
|
||||
pub fn minify_css(_cfg: &Cfg, out: &mut Vec<u8>, code: &[u8]) {
|
||||
// TODO
|
||||
out.extend_from_slice(code);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ pub fn minify_element(
|
|||
attributes: HashMap<Vec<u8>, Vec<u8>>,
|
||||
closing_tag: ElementClosingTag,
|
||||
children: Vec<NodeData>,
|
||||
) -> () {
|
||||
) {
|
||||
let can_omit_closing_tag = cfg.omit_closing_tags
|
||||
&& (can_omit_as_before(tag_name, next_sibling_as_element_tag_name)
|
||||
|| (is_last_child_text_or_element_node && can_omit_as_last_node(parent, tag_name)));
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::cfg::Cfg;
|
||||
|
||||
pub fn minify_instruction(cfg: &Cfg, out: &mut Vec<u8>, code: &[u8], ended: bool) -> () {
|
||||
pub fn minify_instruction(cfg: &Cfg, out: &mut Vec<u8>, code: &[u8], ended: bool) {
|
||||
if !cfg.remove_processing_instructions {
|
||||
out.extend_from_slice(b"<?");
|
||||
out.extend_from_slice(&code);
|
||||
out.extend_from_slice(code);
|
||||
if ended {
|
||||
out.extend_from_slice(b"?>");
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::cfg::Cfg;
|
||||
|
||||
pub fn minify_js(cfg: &Cfg, out: &mut Vec<u8>, code: &[u8]) -> () {
|
||||
pub fn minify_js(_cfg: &Cfg, out: &mut Vec<u8>, code: &[u8]) {
|
||||
// TODO
|
||||
out.extend_from_slice(code);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ impl<'c> Code<'c> {
|
|||
Checkpoint(self.next)
|
||||
}
|
||||
|
||||
pub fn restore_checkpoint(&mut self, cp: Checkpoint) -> () {
|
||||
pub fn restore_checkpoint(&mut self, cp: Checkpoint) {
|
||||
self.next = cp.0;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ impl<'c> Code<'c> {
|
|||
}
|
||||
|
||||
pub fn shift_if_next_in_lookup(&mut self, lookup: &'static Lookup) -> Option<u8> {
|
||||
let c = self.code.get(self.next).filter(|&&n| lookup[n]).map(|&c| c);
|
||||
let c = self.code.get(self.next).filter(|&&n| lookup[n]).copied();
|
||||
if c.is_some() {
|
||||
self.next += 1;
|
||||
};
|
||||
|
@ -62,15 +62,14 @@ impl<'c> Code<'c> {
|
|||
let c = self
|
||||
.code
|
||||
.get(self.next)
|
||||
.filter(|&&n| !lookup[n])
|
||||
.map(|&c| c);
|
||||
.filter(|&&n| !lookup[n]).copied();
|
||||
if c.is_some() {
|
||||
self.next += 1;
|
||||
};
|
||||
c
|
||||
}
|
||||
|
||||
pub fn shift(&mut self, n: usize) -> () {
|
||||
pub fn shift(&mut self, n: usize) {
|
||||
self.next += n;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ fn parse_numeric_entity(
|
|||
// Browsers decode to a replacement character (U+FFFD) if malformed.
|
||||
let char = Some(value)
|
||||
.filter(|_| digits <= max_digits)
|
||||
.and_then(|v| from_u32(v))
|
||||
.and_then(from_u32)
|
||||
.unwrap_or('\u{FFFD}');
|
||||
ParsedEntity {
|
||||
read_len: read_next,
|
||||
|
|
|
@ -3,4 +3,4 @@ pub mod omission;
|
|||
pub mod void;
|
||||
pub mod whitespace;
|
||||
|
||||
pub static EMPTY_SLICE: &'static [u8] = &[];
|
||||
pub static EMPTY_SLICE: &[u8] = &[];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn _eval(src: &'static [u8], expected: &'static [u8], cfg: &super::Cfg) -> () {
|
||||
fn _eval(src: &'static [u8], expected: &'static [u8], cfg: &super::Cfg) {
|
||||
let mut code = src.to_vec();
|
||||
let min = super::minify(&mut code, cfg);
|
||||
assert_eq!(
|
||||
|
@ -7,7 +7,7 @@ fn _eval(src: &'static [u8], expected: &'static [u8], cfg: &super::Cfg) -> () {
|
|||
);
|
||||
}
|
||||
|
||||
fn eval(src: &'static [u8], expected: &'static [u8]) -> () {
|
||||
fn eval(src: &'static [u8], expected: &'static [u8]) {
|
||||
_eval(
|
||||
src,
|
||||
expected,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::gen::codepoints::WHITESPACE;
|
||||
|
||||
pub fn left_trim(val: &mut Vec<u8>) -> () {
|
||||
pub fn left_trim(val: &mut Vec<u8>) {
|
||||
let mut len = 0;
|
||||
while val.get(len).filter(|&&c| WHITESPACE[c]).is_some() {
|
||||
len += 1;
|
||||
|
@ -8,7 +8,7 @@ pub fn left_trim(val: &mut Vec<u8>) -> () {
|
|||
val.drain(0..len);
|
||||
}
|
||||
|
||||
pub fn right_trim(val: &mut Vec<u8>) -> () {
|
||||
pub fn right_trim(val: &mut Vec<u8>) {
|
||||
let mut retain = val.len();
|
||||
while retain > 0 && val.get(retain - 1).filter(|&&c| WHITESPACE[c]).is_some() {
|
||||
retain -= 1;
|
||||
|
@ -16,7 +16,7 @@ pub fn right_trim(val: &mut Vec<u8>) -> () {
|
|||
val.truncate(retain);
|
||||
}
|
||||
|
||||
pub fn collapse_whitespace(val: &mut Vec<u8>) -> () {
|
||||
pub fn collapse_whitespace(val: &mut Vec<u8>) {
|
||||
let mut write = 0;
|
||||
let mut in_whitespace = false;
|
||||
for i in 0..val.len() {
|
||||
|
|
Loading…
Reference in New Issue