diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2025-01-03 18:05:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-03 18:05:18 +0000 |
commit | 36e15b259eb9ee7fc0fdff0acb12d9adc889887c (patch) | |
tree | b4affed9c0f82ba4a846e7d9d15bc7f130523401 | |
parent | Merge pull request #1463 from svenstaro/dependabot/cargo/all-dependencies-435... (diff) | |
parent | Use Self where possible (diff) | |
download | miniserve-36e15b259eb9ee7fc0fdff0acb12d9adc889887c.tar.gz miniserve-36e15b259eb9ee7fc0fdff0acb12d9adc889887c.zip |
Merge pull request #1466 from adamnemecek/master
Use Self where possible.
-rw-r--r-- | src/archive.rs | 24 | ||||
-rw-r--r-- | src/config.rs | 2 | ||||
-rw-r--r-- | src/listing.rs | 4 | ||||
-rw-r--r-- | src/pipe.rs | 2 | ||||
-rw-r--r-- | src/renderer.rs | 8 |
5 files changed, 20 insertions, 20 deletions
diff --git a/src/archive.rs b/src/archive.rs index b8ba4d4..da79ef8 100644 --- a/src/archive.rs +++ b/src/archive.rs @@ -28,27 +28,27 @@ pub enum ArchiveMethod { impl ArchiveMethod { pub fn extension(self) -> String { match self { - ArchiveMethod::TarGz => "tar.gz", - ArchiveMethod::Tar => "tar", - ArchiveMethod::Zip => "zip", + Self::TarGz => "tar.gz", + Self::Tar => "tar", + Self::Zip => "zip", } .to_string() } pub fn content_type(self) -> String { match self { - ArchiveMethod::TarGz => "application/gzip", - ArchiveMethod::Tar => "application/tar", - ArchiveMethod::Zip => "application/zip", + Self::TarGz => "application/gzip", + Self::Tar => "application/tar", + Self::Zip => "application/zip", } .to_string() } pub fn is_enabled(self, tar_enabled: bool, tar_gz_enabled: bool, zip_enabled: bool) -> bool { match self { - ArchiveMethod::TarGz => tar_gz_enabled, - ArchiveMethod::Tar => tar_enabled, - ArchiveMethod::Zip => zip_enabled, + Self::TarGz => tar_gz_enabled, + Self::Tar => tar_enabled, + Self::Zip => zip_enabled, } } @@ -69,9 +69,9 @@ impl ArchiveMethod { { let dir = dir.as_ref(); match self { - ArchiveMethod::TarGz => tar_gz(dir, skip_symlinks, out), - ArchiveMethod::Tar => tar_dir(dir, skip_symlinks, out), - ArchiveMethod::Zip => zip_dir(dir, skip_symlinks, out), + Self::TarGz => tar_gz(dir, skip_symlinks, out), + Self::Tar => tar_dir(dir, skip_symlinks, out), + Self::Zip => zip_dir(dir, skip_symlinks, out), } } } diff --git a/src/config.rs b/src/config.rs index f468365..984f873 100644 --- a/src/config.rs +++ b/src/config.rs @@ -269,7 +269,7 @@ impl MiniserveConfig { .transpose()? .unwrap_or_default(); - Ok(MiniserveConfig { + Ok(Self { verbose: args.verbose, path: args.path.unwrap_or_else(|| PathBuf::from(".")), port, diff --git a/src/listing.rs b/src/listing.rs index a9d2e3a..bd82c94 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -121,7 +121,7 @@ impl Entry { last_modification_date: Option<SystemTime>, symlink_info: Option<String>, ) -> Self { - Entry { + Self { name, entry_type, link, @@ -153,7 +153,7 @@ pub struct Breadcrumb { impl Breadcrumb { fn new(name: String, link: String) -> Self { - Breadcrumb { name, link } + Self { name, link } } } diff --git a/src/pipe.rs b/src/pipe.rs index 51f094a..45ada8b 100644 --- a/src/pipe.rs +++ b/src/pipe.rs @@ -17,7 +17,7 @@ pub struct Pipe { impl Pipe { /// Wrap the given sender in a `Pipe`. pub fn new(destination: Sender<io::Result<Bytes>>) -> Self { - Pipe { + Self { dest: destination, bytes: BytesMut::new(), } diff --git a/src/renderer.rs b/src/renderer.rs index 9c60dcc..28ca2d9 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -326,10 +326,10 @@ pub enum ThemeSlug { impl ThemeSlug { pub fn css(&self) -> &str { match self { - ThemeSlug::Squirrel => grass::include!("data/themes/squirrel.scss"), - ThemeSlug::Archlinux => grass::include!("data/themes/archlinux.scss"), - ThemeSlug::Zenburn => grass::include!("data/themes/zenburn.scss"), - ThemeSlug::Monokai => grass::include!("data/themes/monokai.scss"), + Self::Squirrel => grass::include!("data/themes/squirrel.scss"), + Self::Archlinux => grass::include!("data/themes/archlinux.scss"), + Self::Zenburn => grass::include!("data/themes/zenburn.scss"), + Self::Monokai => grass::include!("data/themes/monokai.scss"), } } |