refactor: clippy fix

This commit is contained in:
Kogia-sima 2020-12-29 05:19:12 +09:00
parent 25fed05519
commit e69d36b168
2 changed files with 5 additions and 18 deletions

View File

@ -185,8 +185,7 @@ fn derive_template_impl(tokens: TokenStream) -> Result<TokenStream, syn::Error>
)?
};
let out_dir = PathBuf::from(env!("OUT_DIR"));
let mut output_file = out_dir.clone();
let mut output_file = PathBuf::from(env!("OUT_DIR"));
output_file.push("templates");
output_file.push(filename_hash(&*input_file));

View File

@ -65,10 +65,7 @@ impl<'a, T: Render + ?Sized> Render for Upper<'a, T> {
let old_len = b.len();
self.0.render(b)?;
let content = b
.as_str()
.get(old_len..)
.ok_or_else(|| RenderError::BufSize)?;
let content = b.as_str().get(old_len..).ok_or(RenderError::BufSize)?;
let s = content.to_uppercase();
unsafe { b._set_len(old_len) };
b.push_str(&*s);
@ -102,10 +99,7 @@ impl<'a, T: Render + ?Sized> Render for Lower<'a, T> {
let old_len = b.len();
self.0.render(b)?;
let content = b
.as_str()
.get(old_len..)
.ok_or_else(|| RenderError::BufSize)?;
let content = b.as_str().get(old_len..).ok_or(RenderError::BufSize)?;
let s = content.to_lowercase();
unsafe { b._set_len(old_len) };
b.push_str(&*s);
@ -161,10 +155,7 @@ impl<'a, T: Render + ?Sized> Render for Trim<'a, T> {
}
fn trim_impl(b: &mut Buffer, old_len: usize) -> Result<(), RenderError> {
let new_contents = b
.as_str()
.get(old_len..)
.ok_or_else(|| RenderError::BufSize)?;
let new_contents = b.as_str().get(old_len..).ok_or(RenderError::BufSize)?;
let trimmed = new_contents.trim();
let trimmed_len = trimmed.len();
@ -238,10 +229,7 @@ fn truncate_impl(
old_len: usize,
limit: usize,
) -> Result<(), RenderError> {
let new_contents = b
.as_str()
.get(old_len..)
.ok_or_else(|| RenderError::BufSize)?;
let new_contents = b.as_str().get(old_len..).ok_or(RenderError::BufSize)?;
if let Some(idx) = new_contents.char_indices().nth(limit).map(|(i, _)| i) {
unsafe { b._set_len(old_len.wrapping_add(idx)) };