fix(clippy): Derive Default where possible

This commit is contained in:
Jalil David Salamé Messina authored and Wez Furlong committed 2023-03-15 10:21:11 -07:00
1 parent fc656c03fe
commit c6dc38b7f3
6 files changed
+23 -88

No files matched your search

+4 -14
View File
@@ -290,33 +290,23 @@ impl Default for BackgroundOrigin {
}
}
#[derive(Debug, Copy, Clone, FromDynamic, ToDynamic, PartialEq)]
#[derive(Debug, Copy, Clone, FromDynamic, ToDynamic, PartialEq, Default)]
pub enum Interpolation {
#[default]
Linear,
Basis,
CatmullRom,
}
impl Default for Interpolation {
fn default() -> Self {
Interpolation::Linear
}
}
#[derive(Debug, Copy, Clone, FromDynamic, ToDynamic, PartialEq)]
#[derive(Debug, Copy, Clone, FromDynamic, ToDynamic, PartialEq, Default)]
pub enum BlendMode {
#[default]
Rgb,
LinearRgb,
Hsv,
Oklab,
}
impl Default for BlendMode {
fn default() -> Self {
BlendMode::Rgb
}
}
#[derive(Debug, Copy, Clone, FromDynamic, ToDynamic, PartialEq)]
pub enum GradientOrientation {
Horizontal,
+10 -35
View File
@@ -1572,9 +1572,10 @@ fn default_inactive_pane_hsb() -> HsbTransform {
}
}
#[derive(FromDynamic, ToDynamic, Clone, Copy, Debug)]
#[derive(FromDynamic, ToDynamic, Clone, Copy, Debug, Default)]
pub enum DefaultCursorStyle {
BlinkingBlock,
#[default]
SteadyBlock,
BlinkingUnderline,
SteadyUnderline,
@@ -1582,12 +1583,6 @@ pub enum DefaultCursorStyle {
SteadyBar,
}
impl Default for DefaultCursorStyle {
fn default() -> Self {
DefaultCursorStyle::SteadyBlock
}
}
impl DefaultCursorStyle {
pub fn effective_shape(self, shape: CursorShape) -> CursorShape {
match shape {
@@ -1648,20 +1643,15 @@ pub enum NewlineCanon {
CarriageReturnAndLineFeed,
}
#[derive(FromDynamic, ToDynamic, Clone, Copy, Debug)]
#[derive(FromDynamic, ToDynamic, Clone, Copy, Debug, Default)]
pub enum WindowCloseConfirmation {
#[default]
AlwaysPrompt,
NeverPrompt,
// TODO: something smart where we see whether the
// running programs are stateful
}
impl Default for WindowCloseConfirmation {
fn default() -> Self {
WindowCloseConfirmation::AlwaysPrompt
}
}
struct PathPossibility {
path: PathBuf,
is_required: bool,
@@ -1682,9 +1672,10 @@ impl PathPossibility {
}
/// Behavior when the program spawned by wezterm terminates
#[derive(Debug, FromDynamic, ToDynamic, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, FromDynamic, ToDynamic, Clone, Copy, PartialEq, Eq, Default)]
pub enum ExitBehavior {
/// Close the associated pane
#[default]
Close,
/// Close the associated pane if the process was successful
CloseOnCleanExit,
@@ -1692,12 +1683,6 @@ pub enum ExitBehavior {
Hold,
}
impl Default for ExitBehavior {
fn default() -> Self {
ExitBehavior::Close
}
}
#[derive(Debug, FromDynamic, ToDynamic, Clone, Copy, PartialEq, Eq)]
pub enum DroppedFileQuoting {
/// No quoting is performed, the file name is passed through as-is
@@ -1762,11 +1747,12 @@ fn default_line_to_ele_shape_cache_size() -> usize {
1024
}
#[derive(Debug, ToDynamic, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, ToDynamic, Clone, Copy, PartialEq, Eq, Default)]
pub enum BoldBrightening {
/// Bold doesn't influence palette selection
No,
/// Bold Shifts palette from 0-7 to 8-15 and preserves bold font
#[default]
BrightAndBold,
/// Bold Shifts palette from 0-7 to 8-15 and removes bold intensity
BrightOnly,
@@ -1795,26 +1781,15 @@ impl FromDynamic for BoldBrightening {
}
}
impl Default for BoldBrightening {
fn default() -> Self {
BoldBrightening::BrightAndBold
}
}
#[derive(Debug, FromDynamic, ToDynamic, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, FromDynamic, ToDynamic, Clone, Copy, PartialEq, Eq, Default)]
pub enum ImePreeditRendering {
/// IME preedit is rendered by WezTerm itself
#[default]
Builtin,
/// IME preedit is rendered by system
System,
}
impl Default for ImePreeditRendering {
fn default() -> Self {
ImePreeditRendering::Builtin
}
}
fn validate_row_or_col(value: &u16) -> Result<(), String> {
if *value < 1 {
Err("initial_cols and initial_rows must be non-zero".to_string())
+4 -14
View File
@@ -662,29 +662,19 @@ impl Default for FontLocatorSelection {
}
}
#[derive(Debug, Clone, Copy, FromDynamic, ToDynamic)]
#[derive(Debug, Clone, Copy, FromDynamic, ToDynamic, Default)]
pub enum FontRasterizerSelection {
#[default]
FreeType,
}
impl Default for FontRasterizerSelection {
fn default() -> Self {
FontRasterizerSelection::FreeType
}
}
#[derive(Debug, Clone, Copy, FromDynamic, ToDynamic)]
#[derive(Debug, Clone, Copy, FromDynamic, ToDynamic, Default)]
pub enum FontShaperSelection {
Allsorts,
#[default]
Harfbuzz,
}
impl Default for FontShaperSelection {
fn default() -> Self {
FontShaperSelection::Harfbuzz
}
}
#[cfg(test)]
mod test {
use super::*;
+2 -7
View File
@@ -1,19 +1,14 @@
use luahelper::impl_lua_conversion_dynamic;
use wezterm_dynamic::{FromDynamic, ToDynamic};
#[derive(Debug, Clone, Copy, PartialEq, Eq, FromDynamic, ToDynamic)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, FromDynamic, ToDynamic, Default)]
pub enum FrontEndSelection {
#[default]
OpenGL,
WebGpu,
Software,
}
impl Default for FrontEndSelection {
fn default() -> Self {
FrontEndSelection::OpenGL
}
}
/// Corresponds to <https://docs.rs/wgpu/latest/wgpu/struct.AdapterInfo.html>
#[derive(Debug, Clone, FromDynamic, ToDynamic)]
pub struct GpuInfo {
+2 -7
View File
@@ -7,22 +7,17 @@ use std::hash::Hash;
/// Specify how FromDynamic will treat unknown fields
/// when converting from Value to a given target type
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)]
pub enum UnknownFieldAction {
/// Don't check, don't warn, don't raise an error
Ignore,
/// Emit a log::warn log
#[default]
Warn,
/// Return an Error
Deny,
}
impl Default for UnknownFieldAction {
fn default() -> UnknownFieldAction {
UnknownFieldAction::Warn
}
}
/// Specify various options for FromDynamic::from_dynamic
#[derive(Copy, Clone, Debug, Default)]
pub struct FromDynamicOptions {
+1 -11
View File
@@ -40,7 +40,7 @@ const BORDER_SIZE: u32 = 12;
const HEADER_SIZE: u32 = 30;
/// Configuration for ConceptFrame
#[derive(Clone)]
#[derive(Clone, Default)]
pub struct ConceptConfig {
pub font_config: Option<Rc<FontConfiguration>>,
pub config: Option<ConfigHandle>,
@@ -56,16 +56,6 @@ impl ConceptConfig {
}
}
impl Default for ConceptConfig {
fn default() -> ConceptConfig {
ConceptConfig {
font_config: None,
default_frame: WindowFrameConfig::default(),
config: None,
}
}
}
/*
* Utilities
*/