Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
fundon committed May 26, 2024
1 parent 6982df9 commit 322f496
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion viz-core/src/into_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ where
fn into_response(self) -> Response {
self.map_or_else(
|| StatusCode::NOT_FOUND.into_response(),
|r| r.into_response(),
IntoResponse::into_response,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion viz-core/src/middleware/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl CookieOptions {

/// Creates new `CookieOptions` with `http_only`
#[must_use]
pub fn http_only(mut self, http_only: bool) -> Self {
pub const fn http_only(mut self, http_only: bool) -> Self {
self.http_only = http_only;
self
}
Expand Down
11 changes: 4 additions & 7 deletions viz-core/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,10 @@ impl ResponseExt for Response {
let value = name
.map_or_else(
|| {
if let Some(filename) =
path.as_ref().file_name().and_then(std::ffi::OsStr::to_str)
{
filename
} else {
"download"
}
path.as_ref()
.file_name()
.and_then(std::ffi::OsStr::to_str)
.map_or("download", |filename| filename)
},
|filename| filename,
)
Expand Down
2 changes: 1 addition & 1 deletion viz-core/src/types/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub enum CookiesError {

impl From<CookiesError> for Error {
fn from(e: CookiesError) -> Self {
Error::Responder(e.into_response())
Self::Responder(e.into_response())
}
}

Expand Down
2 changes: 1 addition & 1 deletion viz-core/src/types/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct Header<T: ?Sized>(pub T);
impl<T> Header<T> {
/// Create new `Header` instance.
#[inline]
pub fn new(t: T) -> Self {
pub const fn new(t: T) -> Self {
Self(t)
}

Expand Down
18 changes: 8 additions & 10 deletions viz-core/src/types/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,15 @@ impl Session {
where
T: DeserializeOwned,
{
let read = self
.lock_data()
self.lock_data()
.read()
.map_err(|e| responder_error((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())))?;

let val = read.get(key).cloned();

match val {
Some(t) => from_value(t).map(Some).map_err(report_error),
None => Ok(None),
}
.map_err(|e| responder_error((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())))?
.get(key)
.cloned()
.map_or_else(
|| Ok(None),
|t| from_value(t).map(Some).map_err(report_error),
)
}

/// Sets a value by the key
Expand Down

0 comments on commit 322f496

Please sign in to comment.