Skip to content

Commit 780081b

Browse files
authored
cargo clippy --fix --all-features -- -Wclippy::use_self (#526)
Follow-up to #502
2 parents c24374c + e33d87e commit 780081b

File tree

10 files changed

+22
-22
lines changed

10 files changed

+22
-22
lines changed

crates/duckdb/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl From<FromSqlError> for Error {
135135
FromSqlError::OutOfRange(val) => Self::IntegralValueOutOfRange(UNKNOWN_COLUMN, val),
136136
#[cfg(feature = "uuid")]
137137
FromSqlError::InvalidUuidSize(_) => {
138-
Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Blob, Box::new(err))
138+
Self::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Blob, Box::new(err))
139139
}
140140
FromSqlError::Other(source) => Self::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Null, source),
141141
_ => Self::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Null, Box::new(err)),

crates/duckdb/src/polars_dataframe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub struct Polars<'stmt> {
1010

1111
impl<'stmt> Polars<'stmt> {
1212
#[inline]
13-
pub(crate) fn new(stmt: &'stmt Statement<'stmt>) -> Polars<'stmt> {
13+
pub(crate) fn new(stmt: &'stmt Statement<'stmt>) -> Self {
1414
Polars { stmt: Some(stmt) }
1515
}
1616

crates/duckdb/src/types/chrono.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl FromSql for NaiveDateTime {
9696
"%F"
9797
}
9898
};
99-
NaiveDateTime::parse_from_str(s, format).map_err(|err| FromSqlError::Other(Box::new(err)))
99+
Self::parse_from_str(s, format).map_err(|err| FromSqlError::Other(Box::new(err)))
100100
}
101101
_ => Err(FromSqlError::InvalidType),
102102
}
@@ -139,7 +139,7 @@ impl FromSql for Duration {
139139

140140
match nanos.try_into() {
141141
Ok(nanos) => {
142-
if let Some(duration) = Duration::new(seconds, nanos) {
142+
if let Some(duration) = Self::new(seconds, nanos) {
143143
Ok(duration)
144144
} else {
145145
Err(FromSqlError::Other("Invalid duration".into()))

crates/duckdb/src/types/from_sql.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl PartialEq for FromSqlError {
3131
(Self::InvalidType, Self::InvalidType) => true,
3232
(Self::OutOfRange(n1), Self::OutOfRange(n2)) => n1 == n2,
3333
#[cfg(feature = "uuid")]
34-
(FromSqlError::InvalidUuidSize(s1), FromSqlError::InvalidUuidSize(s2)) => s1 == s2,
34+
(Self::InvalidUuidSize(s1), Self::InvalidUuidSize(s2)) => s1 == s2,
3535
(..) => false,
3636
}
3737
}
@@ -43,7 +43,7 @@ impl fmt::Display for FromSqlError {
4343
Self::InvalidType => write!(f, "Invalid type"),
4444
Self::OutOfRange(i) => write!(f, "Value {i} out of range"),
4545
#[cfg(feature = "uuid")]
46-
FromSqlError::InvalidUuidSize(s) => {
46+
Self::InvalidUuidSize(s) => {
4747
write!(f, "Cannot read UUID value out of {s} byte blob")
4848
}
4949
Self::Other(ref err) => err.fmt(f),
@@ -240,7 +240,7 @@ impl FromSql for uuid::Uuid {
240240
match value {
241241
ValueRef::Text(..) => value
242242
.as_str()
243-
.and_then(|s| uuid::Uuid::parse_str(s).map_err(|_| FromSqlError::InvalidUuidSize(s.len()))),
243+
.and_then(|s| Self::parse_str(s).map_err(|_| FromSqlError::InvalidUuidSize(s.len()))),
244244
ValueRef::Blob(..) => value
245245
.as_blob()
246246
.and_then(|bytes| {

crates/duckdb/src/types/url.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl FromSql for Url {
2020
match value {
2121
ValueRef::Text(s) => {
2222
let s = std::str::from_utf8(s).map_err(|e| FromSqlError::Other(Box::new(e)))?;
23-
Url::parse(s).map_err(|e| FromSqlError::Other(Box::new(e)))
23+
Self::parse(s).map_err(|e| FromSqlError::Other(Box::new(e)))
2424
}
2525
_ => Err(FromSqlError::InvalidType),
2626
}

crates/duckdb/src/types/value.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ impl From<isize> for Value {
100100
#[cfg(feature = "uuid")]
101101
impl From<uuid::Uuid> for Value {
102102
#[inline]
103-
fn from(id: uuid::Uuid) -> Value {
104-
Value::Text(id.to_string())
103+
fn from(id: uuid::Uuid) -> Self {
104+
Self::Text(id.to_string())
105105
}
106106
}
107107

crates/duckdb/src/vscalar/arrow.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ pub enum ArrowScalarParams {
2323
impl AsRef<[DataType]> for ArrowScalarParams {
2424
fn as_ref(&self) -> &[DataType] {
2525
match self {
26-
ArrowScalarParams::Exact(params) => params.as_ref(),
27-
ArrowScalarParams::Variadic(param) => std::slice::from_ref(param),
26+
Self::Exact(params) => params.as_ref(),
27+
Self::Variadic(param) => std::slice::from_ref(param),
2828
}
2929
}
3030
}
3131

3232
impl From<ArrowScalarParams> for ScalarParams {
3333
fn from(params: ArrowScalarParams) -> Self {
3434
match params {
35-
ArrowScalarParams::Exact(params) => ScalarParams::Exact(
35+
ArrowScalarParams::Exact(params) => Self::Exact(
3636
params
3737
.into_iter()
3838
.map(|v| LogicalTypeId::try_from(&v).expect("type should be converted").into())
3939
.collect(),
4040
),
41-
ArrowScalarParams::Variadic(param) => ScalarParams::Variadic(
41+
ArrowScalarParams::Variadic(param) => Self::Variadic(
4242
LogicalTypeId::try_from(&param)
4343
.expect("type should be converted")
4444
.into(),
@@ -58,15 +58,15 @@ pub struct ArrowFunctionSignature {
5858
impl ArrowFunctionSignature {
5959
/// Create an exact function signature
6060
pub fn exact(params: Vec<DataType>, return_type: DataType) -> Self {
61-
ArrowFunctionSignature {
61+
Self {
6262
parameters: Some(ArrowScalarParams::Exact(params)),
6363
return_type,
6464
}
6565
}
6666

6767
/// Create a variadic function signature
6868
pub fn variadic(param: DataType, return_type: DataType) -> Self {
69-
ArrowFunctionSignature {
69+
Self {
7070
parameters: Some(ArrowScalarParams::Variadic(param)),
7171
return_type,
7272
}
@@ -152,7 +152,7 @@ mod test {
152152

153153
impl Default for MockState {
154154
fn default() -> Self {
155-
MockState {
155+
Self {
156156
info: "some meta".to_string(),
157157
}
158158
}

crates/duckdb/src/vscalar/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl ScalarFunction {
123123
duckdb_scalar_function_set_extra_info(self.ptr, extra_info, destroy);
124124
}
125125

126-
pub fn set_extra_info<T: Default>(&self) -> &ScalarFunction {
126+
pub fn set_extra_info<T: Default>(&self) -> &Self {
127127
unsafe {
128128
let t = Box::new(T::default());
129129
let c_void = Box::into_raw(t) as *mut c_void;

crates/duckdb/src/vscalar/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ pub struct ScalarFunctionSignature {
6363
impl ScalarFunctionSignature {
6464
/// Create an exact function signature
6565
pub fn exact(params: Vec<LogicalTypeHandle>, return_type: LogicalTypeHandle) -> Self {
66-
ScalarFunctionSignature {
66+
Self {
6767
parameters: Some(ScalarParams::Exact(params)),
6868
return_type,
6969
}
7070
}
7171

7272
/// Create a variadic function signature
7373
pub fn variadic(param: LogicalTypeHandle, return_type: LogicalTypeHandle) -> Self {
74-
ScalarFunctionSignature {
74+
Self {
7575
parameters: Some(ScalarParams::Variadic(param)),
7676
return_type,
7777
}
@@ -201,7 +201,7 @@ mod test {
201201

202202
impl Default for TestState {
203203
fn default() -> Self {
204-
TestState { inner: 42 }
204+
Self { inner: 42 }
205205
}
206206
}
207207

crates/duckdb/src/vtab/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl TableFunction {
297297
///
298298
/// # Arguments
299299
/// * `name`: The name of the table function
300-
pub fn set_name(&self, name: &str) -> &TableFunction {
300+
pub fn set_name(&self, name: &str) -> &Self {
301301
unsafe {
302302
let string = CString::from_vec_unchecked(name.as_bytes().into());
303303
duckdb_table_function_set_name(self.ptr, string.as_ptr());

0 commit comments

Comments
 (0)