Use self and const fn where appropriate.
This commit is contained in:
parent
b642d67095
commit
38fa12f7e6
|
@ -48,8 +48,8 @@ pub struct BigFile {
|
|||
}
|
||||
|
||||
impl BigFile {
|
||||
pub fn new() -> BigFile {
|
||||
BigFile {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
text_messages: Default::default(),
|
||||
information: Info::new(),
|
||||
big_files: Default::default(),
|
||||
|
@ -67,15 +67,15 @@ impl BigFile {
|
|||
self.debug_print();
|
||||
}
|
||||
|
||||
pub fn get_big_files(&self) -> &BTreeMap<u64, Vec<FileEntry>> {
|
||||
pub const fn get_big_files(&self) -> &BTreeMap<u64, Vec<FileEntry>> {
|
||||
&self.big_files
|
||||
}
|
||||
|
||||
pub fn get_text_messages(&self) -> &Messages {
|
||||
pub const fn get_text_messages(&self) -> &Messages {
|
||||
&self.text_messages
|
||||
}
|
||||
|
||||
pub fn get_information(&self) -> &Info {
|
||||
pub const fn get_information(&self) -> &Info {
|
||||
&self.information
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ pub struct Directories {
|
|||
pub included_directories: Vec<String>,
|
||||
}
|
||||
impl Directories {
|
||||
pub fn new() -> Directories {
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ pub struct Extensions {
|
|||
}
|
||||
|
||||
impl Extensions {
|
||||
pub fn new() -> Extensions {
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
/// List of allowed extensions, only files with this extensions will be checking if are duplicates
|
||||
|
|
|
@ -8,7 +8,7 @@ pub struct ExcludedItems {
|
|||
}
|
||||
|
||||
impl ExcludedItems {
|
||||
pub fn new() -> ExcludedItems {
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
/// Setting excluded items which needs to contains * wildcard
|
||||
|
|
|
@ -6,7 +6,7 @@ pub struct Messages {
|
|||
}
|
||||
|
||||
impl Messages {
|
||||
pub fn new() -> Messages {
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
pub fn print_messages(&self) {
|
||||
|
|
|
@ -79,8 +79,8 @@ pub struct DuplicateFinder {
|
|||
}
|
||||
|
||||
impl DuplicateFinder {
|
||||
pub fn new() -> DuplicateFinder {
|
||||
DuplicateFinder {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
text_messages: Messages::new(),
|
||||
information: Info::new(),
|
||||
files_with_identical_size: Default::default(),
|
||||
|
@ -106,19 +106,19 @@ impl DuplicateFinder {
|
|||
self.debug_print();
|
||||
}
|
||||
|
||||
pub fn get_files_sorted_by_size(&self) -> &BTreeMap<u64, Vec<FileEntry>> {
|
||||
pub const fn get_files_sorted_by_size(&self) -> &BTreeMap<u64, Vec<FileEntry>> {
|
||||
&self.files_with_identical_size
|
||||
}
|
||||
|
||||
pub fn get_files_sorted_by_hash(&self) -> &BTreeMap<u64, Vec<Vec<FileEntry>>> {
|
||||
pub const fn get_files_sorted_by_hash(&self) -> &BTreeMap<u64, Vec<Vec<FileEntry>>> {
|
||||
&self.files_with_identical_hashes
|
||||
}
|
||||
|
||||
pub fn get_text_messages(&self) -> &Messages {
|
||||
pub const fn get_text_messages(&self) -> &Messages {
|
||||
&self.text_messages
|
||||
}
|
||||
|
||||
pub fn get_information(&self) -> &Info {
|
||||
pub const fn get_information(&self) -> &Info {
|
||||
&self.information
|
||||
}
|
||||
|
||||
|
|
|
@ -52,8 +52,8 @@ pub struct EmptyFiles {
|
|||
}
|
||||
|
||||
impl EmptyFiles {
|
||||
pub fn new() -> EmptyFiles {
|
||||
EmptyFiles {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
text_messages: Messages::new(),
|
||||
information: Info::new(),
|
||||
recursive_search: true,
|
||||
|
@ -73,15 +73,15 @@ impl EmptyFiles {
|
|||
self.debug_print();
|
||||
}
|
||||
|
||||
pub fn get_empty_files(&self) -> &Vec<FileEntry> {
|
||||
pub const fn get_empty_files(&self) -> &Vec<FileEntry> {
|
||||
&self.empty_files
|
||||
}
|
||||
|
||||
pub fn get_text_messages(&self) -> &Messages {
|
||||
pub const fn get_text_messages(&self) -> &Messages {
|
||||
&self.text_messages
|
||||
}
|
||||
|
||||
pub fn get_information(&self) -> &Info {
|
||||
pub const fn get_information(&self) -> &Info {
|
||||
&self.information
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ pub struct Info {
|
|||
pub number_of_empty_folders: usize,
|
||||
}
|
||||
impl Info {
|
||||
pub fn new() -> Info {
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
|
@ -48,8 +48,8 @@ impl Info {
|
|||
/// Method implementation for EmptyFolder
|
||||
impl EmptyFolder {
|
||||
/// New function providing basics values
|
||||
pub fn new() -> EmptyFolder {
|
||||
EmptyFolder {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
information: Default::default(),
|
||||
delete_folders: false,
|
||||
text_messages: Messages::new(),
|
||||
|
@ -58,14 +58,14 @@ impl EmptyFolder {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_empty_folder_list(&self) -> &BTreeMap<String, FolderEntry> {
|
||||
pub const fn get_empty_folder_list(&self) -> &BTreeMap<String, FolderEntry> {
|
||||
&self.empty_folder_list
|
||||
}
|
||||
|
||||
pub fn get_text_messages(&self) -> &Messages {
|
||||
pub const fn get_text_messages(&self) -> &Messages {
|
||||
&self.text_messages
|
||||
}
|
||||
pub fn get_information(&self) -> &Info {
|
||||
pub const fn get_information(&self) -> &Info {
|
||||
&self.information
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ pub struct Info {
|
|||
pub number_of_failed_to_remove_files: usize,
|
||||
}
|
||||
impl Info {
|
||||
pub fn new() -> Info {
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ pub struct Temporary {
|
|||
}
|
||||
|
||||
impl Temporary {
|
||||
pub fn new() -> Temporary {
|
||||
Temporary {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
text_messages: Messages::new(),
|
||||
information: Info::new(),
|
||||
recursive_search: true,
|
||||
|
@ -70,14 +70,14 @@ impl Temporary {
|
|||
self.debug_print();
|
||||
}
|
||||
|
||||
pub fn get_temporary_files(&self) -> &Vec<FileEntry> {
|
||||
pub const fn get_temporary_files(&self) -> &Vec<FileEntry> {
|
||||
&self.temporary_files
|
||||
}
|
||||
pub fn get_text_messages(&self) -> &Messages {
|
||||
pub const fn get_text_messages(&self) -> &Messages {
|
||||
&self.text_messages
|
||||
}
|
||||
|
||||
pub fn get_information(&self) -> &Info {
|
||||
pub const fn get_information(&self) -> &Info {
|
||||
&self.information
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue