style(clippy): enforce clippy use_self lint

Clippy's `use_self` line ensures that `Self` is used instead of the real
name whenever possible. This makes searching easier and cleans up the
code a bit.
This commit is contained in:
Thomas Frans
2023-09-27 21:53:13 +02:00
committed by Henrik Friedrichsen
parent 01e01b59e4
commit fe8f8e78ee
25 changed files with 170 additions and 172 deletions

View File

@@ -17,7 +17,7 @@ pub struct HelpView {
}
impl HelpView {
pub fn new(bindings: HashMap<String, Vec<Command>>) -> HelpView {
pub fn new(bindings: HashMap<String, Vec<Command>>) -> Self {
let mut text = StyledString::styled("Keybindings\n\n", Effect::Bold);
let note = format!(
@@ -43,7 +43,7 @@ impl HelpView {
text.append(binding);
}
HelpView {
Self {
view: ScrollView::new(TextView::new(text)),
}
}

View File

@@ -42,7 +42,7 @@ impl Layout {
ev: &events::EventManager,
theme: Theme,
configuration: Arc<Config>,
) -> Layout {
) -> Self {
let style = ColorStyle::new(
ColorType::Color(*theme.palette.custom("cmdline_bg").unwrap()),
ColorType::Color(*theme.palette.custom("cmdline").unwrap()),
@@ -89,7 +89,7 @@ impl Layout {
event_manager.trigger();
});
Layout {
Self {
screens: HashMap::new(),
stack: HashMap::new(),
statusbar: status.into_boxed_view(),

View File

@@ -8,13 +8,13 @@ pub struct Modal<T: View> {
impl<T: View> Modal<T> {
pub fn new(inner: T) -> Self {
Modal {
Self {
block_events: true,
inner,
}
}
pub fn new_ext(inner: T) -> Self {
Modal {
Self {
block_events: false,
inner,
}

View File

@@ -18,7 +18,7 @@ pub struct ApiResult<I> {
}
impl<I: ListItem + Clone> ApiResult<I> {
pub fn new(limit: u32, fetch_page: Arc<FetchPageFn<I>>) -> ApiResult<I> {
pub fn new(limit: u32, fetch_page: Arc<FetchPageFn<I>>) -> Self {
let items = Arc::new(RwLock::new(Vec::new()));
if let Some(first_page) = fetch_page(0) {
debug!(
@@ -27,7 +27,7 @@ impl<I: ListItem + Clone> ApiResult<I> {
first_page.total
);
items.write().unwrap().extend(first_page.items);
ApiResult {
Self {
offset: Arc::new(RwLock::new(first_page.offset)),
limit,
total: first_page.total,
@@ -35,7 +35,7 @@ impl<I: ListItem + Clone> ApiResult<I> {
fetch_page: fetch_page.clone(),
}
} else {
ApiResult {
Self {
offset: Arc::new(RwLock::new(0)),
limit,
total: 0,
@@ -102,7 +102,7 @@ pub struct Pagination<I: ListItem> {
impl<I: ListItem> Default for Pagination<I> {
fn default() -> Self {
Pagination {
Self {
loaded_content: Arc::new(RwLock::new(0)),
max_content: Arc::new(RwLock::new(None)),
callback: Arc::new(RwLock::new(None)),

View File

@@ -22,10 +22,10 @@ pub struct QueueView {
}
impl QueueView {
pub fn new(queue: Arc<Queue>, library: Arc<Library>) -> QueueView {
pub fn new(queue: Arc<Queue>, library: Arc<Library>) -> Self {
let list = ListView::new(queue.queue.clone(), queue.clone(), library.clone());
QueueView {
Self {
list,
library,
queue,

View File

@@ -37,7 +37,7 @@ pub struct SearchView {
pub const EDIT_ID: &str = "search_edit";
impl SearchView {
pub fn new(events: EventManager, queue: Arc<Queue>, library: Arc<Library>) -> SearchView {
pub fn new(events: EventManager, queue: Arc<Queue>, library: Arc<Library>) -> Self {
let searchfield = EditView::new()
.on_submit(move |s, input| {
if !input.is_empty() {
@@ -52,7 +52,7 @@ impl SearchView {
})
.with_name(EDIT_ID);
SearchView {
Self {
edit: searchfield,
edit_focused: true,
}

View File

@@ -49,7 +49,7 @@ impl SearchResultsView {
events: EventManager,
queue: Arc<Queue>,
library: Arc<Library>,
) -> SearchResultsView {
) -> Self {
let results_tracks = Arc::new(RwLock::new(Vec::new()));
let results_albums = Arc::new(RwLock::new(Vec::new()));
let results_artists = Arc::new(RwLock::new(Vec::new()));
@@ -79,7 +79,7 @@ impl SearchResultsView {
.tab("shows", list_shows.with_title("Podcasts"))
.tab("episodes", list_episodes.with_title("Podcast Episodes"));
let mut view = SearchResultsView {
let mut view = Self {
search_term,
results_tracks,
pagination_tracks,

View File

@@ -22,10 +22,10 @@ pub struct StatusBar {
}
impl StatusBar {
pub fn new(queue: Arc<Queue>, library: Arc<Library>) -> StatusBar {
pub fn new(queue: Arc<Queue>, library: Arc<Library>) -> Self {
let spotify = queue.get_spotify();
StatusBar {
Self {
queue,
spotify,
library,