Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
emuell committed Nov 7, 2024
1 parent c52de6f commit d45889d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ fn generate_random_number<R: rand::Rng>(
if args.is_empty() {
Ok(rand.gen::<LuaNumber>())
} else if args.len() == 1 {
#[allow(clippy::get_first)]
let max = args.get(0).unwrap().as_integer();
if let Some(max) = max {
if max >= 1 {
Expand All @@ -660,6 +661,7 @@ fn generate_random_number<R: rand::Rng>(
))
}
} else if args.len() == 2 {
#[allow(clippy::get_first)]
let min = args.get(0).unwrap().as_integer();
let max = args.get(1).unwrap().as_integer();
if let Some(min) = min {
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl LuaCallback {
let result = self
.function
.call::<LuaValue>((&self.context, arg.clone()))?;
if let Some(inner_function) = result.as_function().cloned().map(|f| f) {
if let Some(inner_function) = result.as_function().cloned() {
// function returned a function -> is a generator. use the inner function instead.
let environment = self.function.environment();
self.environment = environment;
Expand Down
4 changes: 2 additions & 2 deletions src/bindings/unwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub(crate) fn string_from_value(
arg_index: usize,
) -> LuaResult<String> {
if let Some(string) = value.as_string_lossy() {
Ok(string.into())
Ok(string)
} else {
Err(bad_argument_error(
function,
Expand All @@ -130,7 +130,7 @@ pub(crate) fn optional_string_from_value(
arg_index: usize,
) -> LuaResult<String> {
if let Some(string) = value.as_string_lossy() {
Ok(string.into())
Ok(string)
} else if value.is_nil() {
Ok(String::new())
} else {
Expand Down

0 comments on commit d45889d

Please sign in to comment.