use 'Self' keyword to refer to own type (clippy::use_self)

This commit is contained in:
Daniel Eades 2023-12-10 16:32:17 +00:00
parent 12a5804fa7
commit 1ffd464c21
7 changed files with 24 additions and 24 deletions

View file

@ -19,10 +19,10 @@ pub enum Page {
impl Page { impl Page {
const fn as_str(self) -> &'static str { const fn as_str(self) -> &'static str {
match self { match self {
Page::Page1 => "Page 1", Self::Page1 => "Page 1",
Page::Page2 => "Page 2", Self::Page2 => "Page 2",
Page::Page3 => "Page 3", Self::Page3 => "Page 3",
Page::Page4 => "Page 4", Self::Page4 => "Page 4",
} }
} }
} }
@ -94,7 +94,7 @@ impl cosmic::Application for App {
nav_model.activate_position(0); nav_model.activate_position(0);
let mut app = App { core, nav_model }; let mut app = Self { core, nav_model };
let command = app.update_title(); let command = app.update_title();

View file

@ -135,9 +135,9 @@ impl Page {
} }
impl Default for Page { impl Default for Page {
fn default() -> Page { fn default() -> Self {
//TODO: what should the default page be? //TODO: what should the default page be?
Page::Desktop(None) Self::Desktop(None)
} }
} }
@ -214,8 +214,8 @@ pub enum Message {
} }
impl From<Page> for Message { impl From<Page> for Message {
fn from(page: Page) -> Message { fn from(page: Page) -> Self {
Message::Page(page) Self::Page(page)
} }
} }
@ -323,7 +323,7 @@ impl Application for Window {
type Theme = Theme; type Theme = Theme;
fn new(_flags: ()) -> (Self, Command<Self::Message>) { fn new(_flags: ()) -> (Self, Command<Self::Message>) {
let mut window = Window::default() let mut window = Self::default()
.nav_bar_toggled(true) .nav_bar_toggled(true)
.show_maximize(true) .show_maximize(true)
.show_minimize(true); .show_minimize(true);

View file

@ -35,19 +35,19 @@ pub enum ThemeVariant {
impl From<&ThemeType> for ThemeVariant { impl From<&ThemeType> for ThemeVariant {
fn from(theme: &ThemeType) -> Self { fn from(theme: &ThemeType) -> Self {
match theme { match theme {
ThemeType::Light => ThemeVariant::Light, ThemeType::Light => Self::Light,
ThemeType::Dark => ThemeVariant::Dark, ThemeType::Dark => Self::Dark,
ThemeType::HighContrastDark => ThemeVariant::HighContrastDark, ThemeType::HighContrastDark => Self::HighContrastDark,
ThemeType::HighContrastLight => ThemeVariant::HighContrastLight, ThemeType::HighContrastLight => Self::HighContrastLight,
ThemeType::Custom(_) => ThemeVariant::Custom, ThemeType::Custom(_) => Self::Custom,
ThemeType::System(_) => ThemeVariant::System, ThemeType::System(_) => Self::System,
} }
} }
} }
impl From<ThemeType> for ThemeVariant { impl From<ThemeType> for ThemeVariant {
fn from(theme: ThemeType) -> Self { fn from(theme: ThemeType) -> Self {
ThemeVariant::from(&theme) Self::from(&theme)
} }
} }
@ -118,8 +118,8 @@ pub struct State {
} }
impl Default for State { impl Default for State {
fn default() -> State { fn default() -> Self {
State { Self {
checkbox_value: false, checkbox_value: false,
dropdown_selected: Some(0), dropdown_selected: Some(0),
dropdown_options: vec!["Option 1", "Option 2", "Option 3", "Option 4"], dropdown_options: vec!["Option 1", "Option 2", "Option 3", "Option 4"],

View file

@ -42,8 +42,8 @@ pub enum Message {
} }
impl From<Page> for Message { impl From<Page> for Message {
fn from(page: Page) -> Message { fn from(page: Page) -> Self {
Message::Page(page) Self::Page(page)
} }
} }

View file

@ -43,7 +43,7 @@ impl cosmic::Application for MultiWindow {
} }
fn init(core: Core, _input: Self::Flags) -> (Self, cosmic::app::Command<Self::Message>) { fn init(core: Core, _input: Self::Flags) -> (Self, cosmic::app::Command<Self::Message>) {
let windows = MultiWindow { let windows = Self {
windows: HashMap::from([( windows: HashMap::from([(
window::Id::MAIN, window::Id::MAIN,
Window { Window {

View file

@ -68,7 +68,7 @@ impl cosmic::Application for App {
/// Creates the application, and optionally emits command on initialize. /// Creates the application, and optionally emits command on initialize.
fn init(core: Core, _input: Self::Flags) -> (Self, Command<Self::Message>) { fn init(core: Core, _input: Self::Flags) -> (Self, Command<Self::Message>) {
let mut app = App { let mut app = Self {
core, core,
open_sender: None, open_sender: None,
file_contents: String::new(), file_contents: String::new(),

View file

@ -100,7 +100,7 @@ impl Value {
} }
/// Inserts a bunch of graphemes at the given grapheme `index`. /// Inserts a bunch of graphemes at the given grapheme `index`.
pub fn insert_many(&mut self, index: usize, mut value: Value) { pub fn insert_many(&mut self, index: usize, mut value: Self) {
let _ = self let _ = self
.graphemes .graphemes
.splice(index..index, value.graphemes.drain(..)); .splice(index..index, value.graphemes.drain(..));