Skip to content

Commit cc7293d

Browse files
committed
1 parent 0692e76 commit cc7293d

5 files changed

Lines changed: 33 additions & 33 deletions

File tree

ndk/src/event.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ impl InputEvent {
163163
#[doc(alias = "AInputEvent_getType")]
164164
pub unsafe fn from_ptr(ptr: NonNull<ffi::AInputEvent>) -> Self {
165165
match ffi::AInputEvent_getType(ptr.as_ptr()) as u32 {
166-
ffi::AINPUT_EVENT_TYPE_KEY => InputEvent::KeyEvent(KeyEvent::from_ptr(ptr)),
167-
ffi::AINPUT_EVENT_TYPE_MOTION => InputEvent::MotionEvent(MotionEvent::from_ptr(ptr)),
166+
ffi::AINPUT_EVENT_TYPE_KEY => Self::KeyEvent(KeyEvent::from_ptr(ptr)),
167+
ffi::AINPUT_EVENT_TYPE_MOTION => Self::MotionEvent(MotionEvent::from_ptr(ptr)),
168168
x => panic!("Bad event type received: {}", x),
169169
}
170170
}
@@ -173,8 +173,8 @@ impl InputEvent {
173173
#[inline]
174174
pub fn ptr(&self) -> NonNull<ffi::AInputEvent> {
175175
match self {
176-
InputEvent::MotionEvent(MotionEvent { ptr }) => *ptr,
177-
InputEvent::KeyEvent(KeyEvent { ptr }) => *ptr,
176+
Self::MotionEvent(MotionEvent { ptr }) => *ptr,
177+
Self::KeyEvent(KeyEvent { ptr }) => *ptr,
178178
}
179179
}
180180

ndk/src/font.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,51 +37,51 @@ impl FontWeight {
3737
/// The minimum value for the font weight value. Unlike [`ffi::AFONT_WEIGHT_MIN`] being `0`,
3838
/// [`FontWeight::MIN`] is `1` to make the `MIN..MAX` range be inclusive, keeping consistency
3939
/// between [`FontWeight`] and other types like `std::num::NonZeroU*`.
40-
pub const MIN: FontWeight = FontWeight(ffi::AFONT_WEIGHT_MIN as u16 + 1);
40+
pub const MIN: Self = Self(ffi::AFONT_WEIGHT_MIN as u16 + 1);
4141

4242
/// A font weight value for the thin weight.
43-
pub const THIN: FontWeight = FontWeight(ffi::AFONT_WEIGHT_THIN as u16);
43+
pub const THIN: Self = Self(ffi::AFONT_WEIGHT_THIN as u16);
4444

4545
/// A font weight value for the extra-light weight.
46-
pub const EXTRA_LIGHT: FontWeight = FontWeight(ffi::AFONT_WEIGHT_EXTRA_LIGHT as u16);
46+
pub const EXTRA_LIGHT: Self = Self(ffi::AFONT_WEIGHT_EXTRA_LIGHT as u16);
4747

4848
/// A font weight value for the light weight.
49-
pub const LIGHT: FontWeight = FontWeight(ffi::AFONT_WEIGHT_LIGHT as u16);
49+
pub const LIGHT: Self = Self(ffi::AFONT_WEIGHT_LIGHT as u16);
5050

5151
/// A font weight value for the normal weight.
52-
pub const NORMAL: FontWeight = FontWeight(ffi::AFONT_WEIGHT_NORMAL as u16);
52+
pub const NORMAL: Self = Self(ffi::AFONT_WEIGHT_NORMAL as u16);
5353

5454
/// A font weight value for the medium weight.
55-
pub const MEDIUM: FontWeight = FontWeight(ffi::AFONT_WEIGHT_MEDIUM as u16);
55+
pub const MEDIUM: Self = Self(ffi::AFONT_WEIGHT_MEDIUM as u16);
5656

5757
/// A font weight value for the semi-bold weight.
58-
pub const SEMI_BOLD: FontWeight = FontWeight(ffi::AFONT_WEIGHT_SEMI_BOLD as u16);
58+
pub const SEMI_BOLD: Self = Self(ffi::AFONT_WEIGHT_SEMI_BOLD as u16);
5959

6060
/// A font weight value for the bold weight.
61-
pub const BOLD: FontWeight = FontWeight(ffi::AFONT_WEIGHT_BOLD as u16);
61+
pub const BOLD: Self = Self(ffi::AFONT_WEIGHT_BOLD as u16);
6262

6363
/// A font weight value for the extra-bold weight.
64-
pub const EXTRA_BOLD: FontWeight = FontWeight(ffi::AFONT_WEIGHT_EXTRA_BOLD as u16);
64+
pub const EXTRA_BOLD: Self = Self(ffi::AFONT_WEIGHT_EXTRA_BOLD as u16);
6565

6666
/// A font weight value for the black weight.
67-
pub const BLACK: FontWeight = FontWeight(ffi::AFONT_WEIGHT_BLACK as u16);
67+
pub const BLACK: Self = Self(ffi::AFONT_WEIGHT_BLACK as u16);
6868

6969
/// The maximum value for the font weight value.
70-
pub const MAX: FontWeight = FontWeight(ffi::AFONT_WEIGHT_MAX as u16);
70+
pub const MAX: Self = Self(ffi::AFONT_WEIGHT_MAX as u16);
7171
}
7272

7373
impl fmt::Display for FontWeight {
7474
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
7575
f.write_str(match *self {
76-
FontWeight::THIN => "Thin",
77-
FontWeight::EXTRA_LIGHT => "Extra Light (Ultra Light)",
78-
FontWeight::LIGHT => "Light",
79-
FontWeight::NORMAL => "Normal (Regular)",
80-
FontWeight::MEDIUM => "Medium",
81-
FontWeight::SEMI_BOLD => "Semi Bold (Demi Bold)",
82-
FontWeight::BOLD => "Bold",
83-
FontWeight::EXTRA_BOLD => "Extra Bold (Ultra Bold)",
84-
FontWeight::BLACK => "Black (Heavy)",
76+
Self::THIN => "Thin",
77+
Self::EXTRA_LIGHT => "Extra Light (Ultra Light)",
78+
Self::LIGHT => "Light",
79+
Self::NORMAL => "Normal (Regular)",
80+
Self::MEDIUM => "Medium",
81+
Self::SEMI_BOLD => "Semi Bold (Demi Bold)",
82+
Self::BOLD => "Bold",
83+
Self::EXTRA_BOLD => "Extra Bold (Ultra Bold)",
84+
Self::BLACK => "Black (Heavy)",
8585
_ => return writeln!(f, "{}", self.0),
8686
})
8787
}
@@ -103,7 +103,7 @@ impl TryFrom<u16> for FontWeight {
103103
type Error = FontWeightValueError;
104104

105105
fn try_from(value: u16) -> Result<Self, Self::Error> {
106-
FontWeight::new(value)
106+
Self::new(value)
107107
}
108108
}
109109

@@ -434,7 +434,7 @@ impl FontMatcher {
434434
pub fn new() -> Self {
435435
let ptr = NonNull::new(unsafe { ffi::AFontMatcher_create() })
436436
.expect("AFontMatcher_create returned NULL");
437-
unsafe { FontMatcher::from_ptr(ptr) }
437+
unsafe { Self::from_ptr(ptr) }
438438
}
439439

440440
/// Performs the matching from the generic font family for the text and select one font.
@@ -532,7 +532,7 @@ impl SystemFontIterator {
532532
/// Creates a system font iterator.
533533
pub fn new() -> Option<Self> {
534534
NonNull::new(unsafe { ffi::ASystemFontIterator_open() })
535-
.map(|p| unsafe { SystemFontIterator::from_ptr(p) })
535+
.map(|p| unsafe { Self::from_ptr(p) })
536536
}
537537
}
538538

ndk/src/hardware_buffer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ bitflags::bitflags! {
184184
impl HardwareBufferUsage {
185185
/// Helper to read [`HardwareBufferUsage::CPU_READ_MASK`] values.
186186
#[doc(alias = "AHARDWAREBUFFER_USAGE_CPU_READ_MASK")]
187-
pub fn cpu_read(self) -> HardwareBufferUsage {
187+
pub fn cpu_read(self) -> Self {
188188
self.intersection(Self::CPU_READ_MASK)
189189
}
190190

191191
/// Helper to read [`HardwareBufferUsage::CPU_WRITE_MASK`] values.
192192
#[doc(alias = "AHARDWAREBUFFER_USAGE_CPU_WRITE_MASK")]
193-
pub fn cpu_write(self) -> HardwareBufferUsage {
193+
pub fn cpu_write(self) -> Self {
194194
self.intersection(Self::CPU_WRITE_MASK)
195195
}
196196
}

ndk/src/media/image_reader.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ pub enum AcquireResult<T> {
7777
impl<T> AcquireResult<T> {
7878
fn map<U>(self, f: impl FnOnce(T) -> U) -> AcquireResult<U> {
7979
match self {
80-
AcquireResult::Image(img) => AcquireResult::Image(f(img)),
81-
AcquireResult::NoBufferAvailable => AcquireResult::NoBufferAvailable,
82-
AcquireResult::MaxImagesAcquired => AcquireResult::MaxImagesAcquired,
80+
Self::Image(img) => AcquireResult::Image(f(img)),
81+
Self::NoBufferAvailable => AcquireResult::NoBufferAvailable,
82+
Self::MaxImagesAcquired => AcquireResult::MaxImagesAcquired,
8383
}
8484
}
8585
}

ndk/src/surface_texture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl SurfaceTexture {
5151
pub unsafe fn from_surface_texture(env: *mut JNIEnv, surface_texture: jobject) -> Option<Self> {
5252
let a_surface_texture_ptr = ffi::ASurfaceTexture_fromSurfaceTexture(env, surface_texture);
5353
let s = NonNull::new(a_surface_texture_ptr)?;
54-
Some(SurfaceTexture::from_ptr(s))
54+
Some(Self::from_ptr(s))
5555
}
5656

5757
/// Returns a pointer to the native [`ffi::ASurfaceTexture`].

0 commit comments

Comments
 (0)