diff --git a/plugins/chop/generator/src/lib.rs b/plugins/chop/generator/src/lib.rs index bfe8b51..3bf2462 100644 --- a/plugins/chop/generator/src/lib.rs +++ b/plugins/chop/generator/src/lib.rs @@ -73,7 +73,7 @@ impl Chop for GeneratorChop { 1.0 }; let cur_value = cur_value * scale; - output[i][j] = cur_value as f32; + output[i][j] = cur_value; } } } diff --git a/plugins/chop/python/src/lib.rs b/plugins/chop/python/src/lib.rs index c069254..d1728e5 100644 --- a/plugins/chop/python/src/lib.rs +++ b/plugins/chop/python/src/lib.rs @@ -212,7 +212,7 @@ impl InfoChop for PythonChop { fn channel(&self, index: usize) -> (String, f32) { match index { 0 => ("execute_count".to_string(), self.execute_count as f32), - 1 => ("offset".to_string(), self.offset as f32), + 1 => ("offset".to_string(), self.offset), _ => panic!("Invalid channel index"), } } diff --git a/plugins/dat/filter/src/lib.rs b/plugins/dat/filter/src/lib.rs index b41773a..00c1e86 100644 --- a/plugins/dat/filter/src/lib.rs +++ b/plugins/dat/filter/src/lib.rs @@ -69,18 +69,18 @@ impl FilterDat { output.set_table_size(rows, cols); for row in 0..rows { for col in 0..cols { - if let Some(cell) = input.cell(row.clone(), col) { + if let Some(cell) = input.cell(row, col) { match self.params.case { FilterType::UpperCamelCase => { - let formatted = to_camel_case(cell, self.params.keep_spaces.clone()); + let formatted = to_camel_case(cell, self.params.keep_spaces); output[[row, col]] = formatted; } FilterType::LowerCase => { - let formatted = to_lower_case(cell, self.params.keep_spaces.clone()); + let formatted = to_lower_case(cell, self.params.keep_spaces); output[[row, col]] = formatted; } FilterType::UpperCase => { - let formatted = to_upper_case(cell, self.params.keep_spaces.clone()); + let formatted = to_upper_case(cell, self.params.keep_spaces); output[[row, col]] = formatted; } } @@ -93,15 +93,15 @@ impl FilterDat { let mut output = output.text(); match self.params.case { FilterType::UpperCamelCase => { - let formatted = to_camel_case(input.text(), self.params.keep_spaces.clone()); + let formatted = to_camel_case(input.text(), self.params.keep_spaces); output.set_text(&formatted); } FilterType::LowerCase => { - let formatted = to_lower_case(input.text(), self.params.keep_spaces.clone()); + let formatted = to_lower_case(input.text(), self.params.keep_spaces); output.set_text(&formatted); } FilterType::UpperCase => { - let formatted = to_upper_case(input.text(), self.params.keep_spaces.clone()); + let formatted = to_upper_case(input.text(), self.params.keep_spaces); output.set_text(&formatted); } } diff --git a/plugins/top/cpu-memory-top/src/frame_queue.rs b/plugins/top/cpu-memory-top/src/frame_queue.rs index 74fdf3f..ecb0bc4 100644 --- a/plugins/top/cpu-memory-top/src/frame_queue.rs +++ b/plugins/top/cpu-memory-top/src/frame_queue.rs @@ -36,13 +36,13 @@ impl FrameQueue { if let Some(b) = &old_buf { if b.size() < byte_size || b.size() > byte_size * 2 || b.flags() != flags { let mut ctx = self.context.lock().unwrap(); - return Some(ctx.create_output_buffer(byte_size as usize, flags)); + return Some(ctx.create_output_buffer(byte_size, flags)); } return old_buf; } } let mut ctx = self.context.lock().unwrap(); - Some(ctx.create_output_buffer(byte_size as usize, flags)) + Some(ctx.create_output_buffer(byte_size, flags)) } pub fn update_complete(&self, buf_info: BufferInfo) { diff --git a/td-rs-base/src/chop.rs b/td-rs-base/src/chop.rs index f6e80a9..cc9720c 100644 --- a/td-rs-base/src/chop.rs +++ b/td-rs-base/src/chop.rs @@ -29,7 +29,7 @@ impl ChopInput { unsafe { std::slice::from_raw_parts( - *self.input.channelData.offset(index as isize), + *self.input.channelData.add(index), self.input.numSamples as usize, ) } diff --git a/td-rs-base/src/param.rs b/td-rs-base/src/param.rs index 9727c2b..041a1fa 100644 --- a/td-rs-base/src/param.rs +++ b/td-rs-base/src/param.rs @@ -587,11 +587,7 @@ impl Param for ChopParam { impl ChopParam { /// Get the chop input for this parameter, if it exists. pub fn input(&self) -> Option<&ChopInput> { - if let Some(input) = self.input { - Some(unsafe { ChopInput::ref_cast(&*input) }) - } else { - None - } + self.input.map(|input| unsafe { ChopInput::ref_cast(&*input) }) } } @@ -614,11 +610,7 @@ impl Param for SopParam { impl SopParam { /// Get the sop input for this parameter, if it exists. pub fn input(&self) -> Option<&SopInput> { - if let Some(input) = self.input { - Some(unsafe { SopInput::ref_cast(&*input) }) - } else { - None - } + self.input.map(|input| unsafe { SopInput::ref_cast(&*input) }) } } @@ -641,11 +633,7 @@ impl Param for TopParam { impl TopParam { /// Get the top input for this parameter, if it exists. pub fn input(&self) -> Option<&crate::top::TopInput> { - if let Some(input) = self.input { - Some(unsafe { crate::top::TopInput::ref_cast(&*input) }) - } else { - None - } + self.input.map(|input| unsafe { crate::top::TopInput::ref_cast(&*input) }) } } @@ -668,11 +656,7 @@ impl Param for DatParam { impl DatParam { /// Get the dat input for this parameter, if it exists. pub fn input(&self) -> Option<&crate::dat::DatInput> { - if let Some(input) = self.input { - Some(unsafe { crate::dat::DatInput::ref_cast(&*input) }) - } else { - None - } + self.input.map(|input| unsafe { crate::dat::DatInput::ref_cast(&*input) }) } } diff --git a/td-rs-base/src/sop.rs b/td-rs-base/src/sop.rs index 99f0a6d..753cc88 100644 --- a/td-rs-base/src/sop.rs +++ b/td-rs-base/src/sop.rs @@ -1,3 +1,5 @@ +#![allow(non_snake_case)] + use crate::cxx::SOP_CustomAttribInfo; use crate::{cxx, GetInput, OperatorInputs}; use auto_ops::impl_op_ex; diff --git a/td-rs-chop/src/lib.rs b/td-rs-chop/src/lib.rs index 830a62e..ce3e5a6 100644 --- a/td-rs-chop/src/lib.rs +++ b/td-rs-chop/src/lib.rs @@ -63,8 +63,8 @@ impl<'execute> ChopOutput<'execute> { } unsafe { - let channel_ptr = *self.output.channels.offset(index as isize); - std::slice::from_raw_parts(channel_ptr, self.num_samples() as usize) + let channel_ptr = *self.output.channels.add(index); + std::slice::from_raw_parts(channel_ptr, self.num_samples()) } } @@ -74,8 +74,8 @@ impl<'execute> ChopOutput<'execute> { } unsafe { - let channel_ptr = *self.output.channels.offset(index as isize); - std::slice::from_raw_parts_mut(channel_ptr, self.num_samples() as usize) + let channel_ptr = *self.output.channels.add(index); + std::slice::from_raw_parts_mut(channel_ptr, self.num_samples()) } } } diff --git a/td-rs-dat/src/lib.rs b/td-rs-dat/src/lib.rs index df9f883..f7e007f 100644 --- a/td-rs-dat/src/lib.rs +++ b/td-rs-dat/src/lib.rs @@ -106,7 +106,7 @@ impl<'execute> CellType<'execute> for f64 { let ptr = table.table.as_ptr(); unsafe { - let y = ptr.offset(offset as isize) as *mut f64; + let y = ptr.add(offset) as *mut f64; *y = out; } @@ -116,7 +116,7 @@ impl<'execute> CellType<'execute> for f64 { fn set(table: &mut DatTableOutput, row: usize, col: usize, value: Self) { let [rows, _] = table.table_size(); let offset = row * rows + col; - table.table[offset] = value.clone(); + table.table[offset] = value; table .output .as_mut() @@ -138,7 +138,7 @@ impl<'execute> CellType<'execute> for i32 { let ptr = table.table.as_ptr(); unsafe { - let y = ptr.offset(offset.clone() as isize) as *mut i32; + let y = ptr.add(offset) as *mut i32; *y = out; } @@ -146,9 +146,9 @@ impl<'execute> CellType<'execute> for i32 { } fn set(table: &mut DatTableOutput, row: usize, col: usize, value: Self) { - let rows = table.table_size()[0].clone(); - let offset = row.clone() * rows + col.clone(); - table.table[offset] = value.clone(); + let rows = table.table_size()[0]; + let offset = row * rows + col; + table.table[offset] = value; table .output .as_mut() @@ -158,8 +158,8 @@ impl<'execute> CellType<'execute> for i32 { impl<'execute> CellType<'execute> for String { fn get<'a>(table: &'a DatTableOutput<'execute, Self>, row: usize, col: usize) -> &'a Self { - let rows = table.table_size()[0].clone(); - let offset = row.clone() * rows + col.clone(); + let rows = table.table_size()[0]; + let offset = row * rows + col; let out = unsafe { let out = table.output.as_ref().getCellString(row as i32, col as i32); std::ffi::CStr::from_ptr(out).to_str().unwrap() @@ -168,7 +168,7 @@ impl<'execute> CellType<'execute> for String { let ptr = table.table.as_ptr(); unsafe { - let y = ptr.offset(offset.clone() as isize) as *mut &str; + let y = ptr.add(offset) as *mut &str; *y = out; } diff --git a/td-rs-derive-py/src/lib.rs b/td-rs-derive-py/src/lib.rs index acf1672..fdfef31 100644 --- a/td-rs-derive-py/src/lib.rs +++ b/td-rs-derive-py/src/lib.rs @@ -292,7 +292,7 @@ pub fn py_op_methods(_attr: TokenStream, item: TokenStream) -> TokenStream { let generated_functions: Vec<_> = input.items.iter().filter_map(|item| { if let syn::ImplItem::Method(method) = item { - let has_py_meth = method.attrs.iter().any(|attr| is_py_meth_attr(&attr)); + let has_py_meth = method.attrs.iter().any(is_py_meth_attr); if has_py_meth { let fn_name = &method.sig.ident; Some(PyMeth { diff --git a/td-rs-derive/src/lib.rs b/td-rs-derive/src/lib.rs index e61522a..7d30fd0 100644 --- a/td-rs-derive/src/lib.rs +++ b/td-rs-derive/src/lib.rs @@ -1,7 +1,7 @@ extern crate proc_macro; use proc_macro::TokenStream; -use proc_macro2::TokenStream as TokenStream2; + use quote::quote; @@ -165,9 +165,9 @@ fn impl_params(input: &DeriveInput) -> TokenStream { let field_name_upper = format_name(&field_name.to_string()); let default_label = format!("{}", field_name); - let label = label.unwrap_or_else(|| default_label); + let label = label.unwrap_or(default_label); let default_page = "Custom".to_string(); - let page = page.unwrap_or_else(|| default_page); + let page = page.unwrap_or(default_page); let min = min.unwrap_or(0.0); let max = max.unwrap_or(1.0); @@ -225,5 +225,5 @@ fn capitalize_first(s: &str) -> String { } fn remove_underscores(s: &str) -> String { - s.replace("_", "") + s.replace('_', "") } diff --git a/td-rs-xtask/src/lib.rs b/td-rs-xtask/src/lib.rs index a3da195..5e43d41 100644 --- a/td-rs-xtask/src/lib.rs +++ b/td-rs-xtask/src/lib.rs @@ -18,7 +18,7 @@ use std::process::Command; pub use anyhow::Result; -const PLUGIN_HOME: &'static str = "target/plugin"; +const PLUGIN_HOME: &str = "target/plugin"; pub fn build(packages: &[&str], args: &[&str]) -> Result<()> { let package_args = packages.iter().flat_map(|package| ["-p", package]); diff --git a/td-rs-xtask/src/macos/mod.rs b/td-rs-xtask/src/macos/mod.rs index a39f550..0c1071b 100644 --- a/td-rs-xtask/src/macos/mod.rs +++ b/td-rs-xtask/src/macos/mod.rs @@ -12,7 +12,7 @@ pub(crate) fn install_plugin( plugin: &str, _plugin_type: PluginType, ) -> anyhow::Result<()> { - let plugin = &plugin.replace("-", "_"); + let plugin = &plugin.replace('-', "_"); let plugin_target_path = plugin_target_path(plugin).join(format!("{plugin}.plugin")); let td_plugin_folder = &config.macos.plugin_folder; println!( @@ -43,27 +43,27 @@ pub(crate) fn build_plugin( &["--release", &format!("--target={target}")], )?; - let plugin = &plugin.replace("-", "_"); + let plugin = &plugin.replace('-', "_"); let path = pbxproj_path(plugin); println!("Writing xcode project to {:?}", path); - write_xcodeproj(&target, &plugin, &plugin_type, &path)?; + write_xcodeproj(target, plugin, &plugin_type, &path)?; println!("Building xcode project"); - build_xcode(config, &plugin)?; + build_xcode(config, plugin)?; println!("Moving plugin to {:?}", PLUGIN_HOME); move_plugin(plugin, &path)?; Ok(()) } fn move_plugin(plugin: &str, path: &PathBuf) -> anyhow::Result<()> { - fs_extra::dir::remove(&path.parent().unwrap()) + fs_extra::dir::remove(path.parent().unwrap()) .context("Could not remove xcode project directory")?; let plugin_build_path = format!("build/Release/{plugin}.plugin"); let plugin_target_path = plugin_target_path(plugin); std::fs::create_dir_all(&plugin_target_path).context("Could not create plugin directory")?; - fs_extra::dir::remove(&plugin_target_path.join(format!("{plugin}.plugin"))) + fs_extra::dir::remove(plugin_target_path.join(format!("{plugin}.plugin"))) .context("Could not remove plugin directory")?; - fs_extra::dir::move_dir(&plugin_build_path, &plugin_target_path, &CopyOptions::new()) + fs_extra::dir::move_dir(plugin_build_path, &plugin_target_path, &CopyOptions::new()) .context("Could not move plugin to target directory")?; Ok(()) } @@ -101,13 +101,13 @@ fn write_xcodeproj( plugin_type: &PluginType, path: &PathBuf, ) -> anyhow::Result<()> { - const LIB_KEY: &'static str = "9E4ACB8B299AC54200A2B1CE"; - const BUNDLE_KEY: &'static str = "E23329D61DF092AD0002B4FE"; - const BUNDLE_CONFIGURATION_KEY: &'static str = "E23329D51DF092AD0002B4FE"; + const LIB_KEY: &str = "9E4ACB8B299AC54200A2B1CE"; + const BUNDLE_KEY: &str = "E23329D61DF092AD0002B4FE"; + const BUNDLE_CONFIGURATION_KEY: &str = "E23329D51DF092AD0002B4FE"; let plugin_type_name = plugin_type.to_short_name(); - std::fs::create_dir_all(&path.parent().unwrap()) + std::fs::create_dir_all(path.parent().unwrap()) .context("Could not create xcode project directory")?; let mut project = Value::from_file(format!( "td-rs-xtask/xcode/{plugin_type_name}/project.pbxproj" @@ -135,10 +135,10 @@ fn write_xcodeproj( .unwrap() .as_dictionary_mut() .unwrap(); - bundle_config.insert("name".to_string(), Value::String(format!("{plugin}"))); + bundle_config.insert("name".to_string(), Value::String(plugin.to_string())); bundle_config.insert( "productName".to_string(), - Value::String(format!("{plugin}")), + Value::String(plugin.to_string()), ); project.to_file_xml(path)?; Ok(())