Skip to content

Commit

Permalink
ndk: Remove and warn on trivial casts
Browse files Browse the repository at this point in the history
`trivial-casts` is allowed by default as it still has some odd cases
where the lint triggers incorrectly or is difficult to fix.  For our
intents and purposes however it works just fine and prevents against
riddling the code with unnecessary - usually untyped - `as` casts.

https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#explanation-22
  • Loading branch information
MarijnS95 committed Jan 24, 2022
1 parent 3c5d01e commit e0c81dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ndk/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl Configuration {
pub fn country(&self) -> String {
let mut result = " ".to_owned();
unsafe {
ffi::AConfiguration_getCountry(self.ptr.as_ptr(), result.as_mut_ptr() as *mut _);
ffi::AConfiguration_getCountry(self.ptr.as_ptr(), result.as_mut_ptr());
}
result
}
Expand Down Expand Up @@ -172,11 +172,11 @@ impl Configuration {
}
}

/// Returns the language, as a `String` of two characters, if a language is set
/// Returns the language, as a [`String`] of two characters, if a language is set
pub fn language(&self) -> Option<String> {
let mut chars = [0u8; 2];
unsafe {
ffi::AConfiguration_getLanguage(self.ptr.as_ptr(), chars[..].as_mut_ptr() as *mut _);
ffi::AConfiguration_getLanguage(self.ptr.as_ptr(), chars.as_mut_ptr());
}
if chars[0] == 0 {
None
Expand Down
2 changes: 1 addition & 1 deletion ndk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
feature = "native_app_glue",
doc = " * `native_app_glue`'s `AndroidApp`, in the `android_app` module"
)]
#![warn(missing_debug_implementations)]
#![warn(missing_debug_implementations, trivial_casts)]

pub mod asset;
pub mod bitmap;
Expand Down

0 comments on commit e0c81dd

Please sign in to comment.