rust: Use Self wherever possible

Use Self instead of the struct name whenever possible.
Automagically replace struct name with Self:
`cargo clippy --fix -- -W clippy::use_self`

This streamlines the code.

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Steffen Eiden
2024-10-15 14:01:22 +02:00
committed by Jan Höppner
parent 300f8d23b5
commit d30d272523
19 changed files with 98 additions and 98 deletions
+3 -3
View File
@@ -39,11 +39,11 @@ impl fmt::Debug for AkidCheckResult {
}
impl AkidCheckResult {
pub const OK: AkidCheckResult = AkidCheckResult(openssl_sys::X509_V_OK);
pub const OK: Self = Self(openssl_sys::X509_V_OK);
/// Creates an `AkidCheckResult` from a raw error number.
unsafe fn from_raw(err: c_int) -> AkidCheckResult {
AkidCheckResult(err)
unsafe fn from_raw(err: c_int) -> Self {
Self(err)
}
}
+1 -1
View File
@@ -73,7 +73,7 @@ impl X509StoreContextExtension for X509StoreContextRef {
with_context: F,
) -> Result<T, ErrorStack>
where
F: FnOnce(&mut X509StoreContextRef) -> Result<T, ErrorStack>,
F: FnOnce(&mut Self) -> Result<T, ErrorStack>,
{
struct Cleanup<'a>(&'a mut X509StoreContextRef);
@@ -20,8 +20,8 @@ impl ForeignType for StackableX509Crl {
type CType = openssl_sys::X509_CRL;
type Ref = X509CrlRef;
unsafe fn from_ptr(ptr: *mut openssl_sys::X509_CRL) -> StackableX509Crl {
StackableX509Crl(ptr)
unsafe fn from_ptr(ptr: *mut openssl_sys::X509_CRL) -> Self {
Self(ptr)
}
fn as_ptr(&self) -> *mut openssl_sys::X509_CRL {
@@ -132,7 +132,7 @@ impl From<X509Crl> for StackableX509Crl {
fn from(value: X509Crl) -> Self {
unsafe {
openssl_sys::X509_CRL_up_ref(value.as_ptr());
StackableX509Crl::from_ptr(value.as_ptr())
Self::from_ptr(value.as_ptr())
}
}
}
@@ -140,7 +140,7 @@ impl From<StackableX509Crl> for X509Crl {
fn from(value: StackableX509Crl) -> Self {
unsafe {
openssl_sys::X509_CRL_up_ref(value.as_ptr());
X509Crl::from_ptr(value.as_ptr())
Self::from_ptr(value.as_ptr())
}
}
}