Skip to content

Commit 4142c04

Browse files
authored
Replace all Into with From (tikv#4792)
Signed-off-by: Iosmanthus Teng <myosmanthustree@gmail.com>
1 parent 7ba0365 commit 4142c04

9 files changed

Lines changed: 32 additions & 32 deletions

File tree

components/cop_datatype/src/builder/field_type.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ impl FieldTypeBuilder {
4242
}
4343
}
4444

45-
impl Into<FieldType> for FieldTypeBuilder {
46-
fn into(self) -> FieldType {
47-
self.build()
45+
impl From<FieldTypeBuilder> for FieldType {
46+
fn from(fp_builder: FieldTypeBuilder) -> FieldType {
47+
fp_builder.build()
4848
}
4949
}

components/cop_datatype/src/def/field_type.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,18 +309,18 @@ impl FieldTypeAccessor for ColumnInfo {
309309
}
310310
}
311311

312-
impl Into<FieldType> for FieldTypeTp {
313-
fn into(self) -> FieldType {
312+
impl From<FieldTypeTp> for FieldType {
313+
fn from(fp: FieldTypeTp) -> FieldType {
314314
let mut ft = FieldType::new();
315-
ft.as_mut_accessor().set_tp(self);
315+
ft.as_mut_accessor().set_tp(fp);
316316
ft
317317
}
318318
}
319319

320-
impl Into<ColumnInfo> for FieldTypeTp {
321-
fn into(self) -> ColumnInfo {
320+
impl From<FieldTypeTp> for ColumnInfo {
321+
fn from(fp: FieldTypeTp) -> ColumnInfo {
322322
let mut ft = ColumnInfo::new();
323-
ft.as_mut_accessor().set_tp(self);
323+
ft.as_mut_accessor().set_tp(fp);
324324
ft
325325
}
326326
}

components/engine/src/rocks/util/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ pub enum CompressionType {
1515
ZstdNotFinal,
1616
}
1717

18-
impl Into<DBCompressionType> for CompressionType {
19-
fn into(self) -> DBCompressionType {
20-
match self {
18+
impl From<CompressionType> for DBCompressionType {
19+
fn from(compression_type: CompressionType) -> DBCompressionType {
20+
match compression_type {
2121
CompressionType::No => DBCompressionType::No,
2222
CompressionType::Snappy => DBCompressionType::Snappy,
2323
CompressionType::Zlib => DBCompressionType::Zlib,

components/tikv_util/src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ impl<'de> Deserialize<'de> for ReadableSize {
221221
#[derive(Clone, Debug, PartialEq)]
222222
pub struct ReadableDuration(pub Duration);
223223

224-
impl Into<Duration> for ReadableDuration {
225-
fn into(self) -> Duration {
226-
self.0
224+
impl From<ReadableDuration> for Duration {
225+
fn from(readable: ReadableDuration) -> Duration {
226+
readable.0
227227
}
228228
}
229229

components/tipb_helper/src/expr_def_builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ impl ExprDefBuilder {
9090
}
9191
}
9292

93-
impl Into<Expr> for ExprDefBuilder {
94-
fn into(self) -> Expr {
95-
self.build()
93+
impl From<ExprDefBuilder> for Expr {
94+
fn from(expr_def_builder: ExprDefBuilder) -> Expr {
95+
expr_def_builder.build()
9696
}
9797
}

src/coprocessor/codec/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ impl Error {
147147
}
148148
}
149149

150-
impl Into<select::Error> for Error {
151-
fn into(self) -> select::Error {
150+
impl From<Error> for select::Error {
151+
fn from(error: Error) -> select::Error {
152152
let mut err = select::Error::new();
153-
err.set_code(self.code());
154-
err.set_msg(format!("{:?}", self));
153+
err.set_code(error.code());
154+
err.set_msg(format!("{:?}", error));
155155
err
156156
}
157157
}

src/coprocessor/codec/mysql/time/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ pub enum TimeType {
189189
Timestamp,
190190
}
191191

192-
impl Into<FieldTypeTp> for TimeType {
193-
fn into(self) -> FieldTypeTp {
194-
match self {
192+
impl From<TimeType> for FieldTypeTp {
193+
fn from(time_type: TimeType) -> FieldTypeTp {
194+
match time_type {
195195
TimeType::Date => FieldTypeTp::Date,
196196
TimeType::DateTime => FieldTypeTp::DateTime,
197197
TimeType::Timestamp => FieldTypeTp::Timestamp,

src/raftstore/errors.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,12 @@ quick_error! {
142142

143143
pub type Result<T> = result::Result<T, Error>;
144144

145-
impl Into<errorpb::Error> for Error {
146-
fn into(self) -> errorpb::Error {
145+
impl From<Error> for errorpb::Error {
146+
fn from(err: Error) -> errorpb::Error {
147147
let mut errorpb = errorpb::Error::new();
148-
errorpb.set_message(error::Error::description(&self).to_owned());
148+
errorpb.set_message(error::Error::description(&err).to_owned());
149149

150-
match self {
150+
match err {
151151
Error::RegionNotFound(region_id) => {
152152
errorpb.mut_region_not_found().set_region_id(region_id);
153153
}

src/server/debug.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ impl From<debugpb::BottommostLevelCompaction> for BottommostLevelCompaction {
116116
}
117117
}
118118

119-
impl Into<debugpb::BottommostLevelCompaction> for BottommostLevelCompaction {
120-
fn into(self) -> debugpb::BottommostLevelCompaction {
121-
match self.0 {
119+
impl From<BottommostLevelCompaction> for debugpb::BottommostLevelCompaction {
120+
fn from(bottommost: BottommostLevelCompaction) -> debugpb::BottommostLevelCompaction {
121+
match bottommost.0 {
122122
DBBottommostLevelCompaction::Skip => debugpb::BottommostLevelCompaction::Skip,
123123
DBBottommostLevelCompaction::Force => debugpb::BottommostLevelCompaction::Force,
124124
DBBottommostLevelCompaction::IfHaveCompactionFilter => {

0 commit comments

Comments
 (0)