Skip to content

Commit bc46d4f

Browse files
committed
chore(rad): cargo clippy
1 parent 7577300 commit bc46d4f

2 files changed

Lines changed: 11 additions & 21 deletions

File tree

rad/src/operators/string.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn as_bytes(input: &RadonString, args: &Option<Vec<Value>>) -> Result<RadonB
4040
let wrong_args = || RadError::WrongArguments {
4141
input_type: RadonString::radon_type_name(),
4242
operator: "AsBytes".to_string(),
43-
args: args.to_owned().unwrap_or(Vec::<Value>::default()).to_vec(),
43+
args: args.to_owned().unwrap_or_default().to_vec(),
4444
};
4545
let mut input_string = input.value();
4646
if input_string.starts_with("0x") {
@@ -50,16 +50,13 @@ pub fn as_bytes(input: &RadonString, args: &Option<Vec<Value>>) -> Result<RadonB
5050
input_string.insert(0, '0');
5151
}
5252
let mut bytes_encoding = RadonBytesEncoding::Hex;
53-
match args {
54-
Some(args) => {
55-
if args.len() > 0 {
56-
let arg = args.first().ok_or_else(wrong_args)?.to_owned();
57-
let bytes_encoding_u8 = from_value::<u8>(arg).map_err(|_| wrong_args())?;
58-
bytes_encoding =
59-
RadonBytesEncoding::try_from(bytes_encoding_u8).map_err(|_| wrong_args())?;
60-
}
53+
if let Some(args) = args {
54+
if !args.is_empty() {
55+
let arg = args.first().ok_or_else(wrong_args)?.to_owned();
56+
let bytes_encoding_u8 = from_value::<u8>(arg).map_err(|_| wrong_args())?;
57+
bytes_encoding =
58+
RadonBytesEncoding::try_from(bytes_encoding_u8).map_err(|_| wrong_args())?;
6159
}
62-
_ => (),
6360
}
6461
match bytes_encoding {
6562
RadonBytesEncoding::Hex => Ok(RadonBytes::from(

rad/src/types/string.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ impl Operable for RadonString {
121121
string_operators::as_bool(self).map(RadonTypes::from)
122122
}
123123
(RadonOpCodes::StringAsBytes, args) => string_operators::as_bytes(self, args)
124-
.map(RadonTypes::from)
125-
.map_err(Into::into),
124+
.map(RadonTypes::from),
126125
(RadonOpCodes::StringLength, None) => {
127126
Ok(RadonTypes::from(string_operators::length(self)))
128127
}
@@ -140,19 +139,13 @@ impl Operable for RadonString {
140139
}
141140
(RadonOpCodes::StringReplace, Some(args)) => {
142141
string_operators::string_replace(self, args.as_slice())
143-
.map(RadonTypes::from)
144-
.map_err(Into::into)
145-
}
142+
.map(RadonTypes::from)}
146143
(RadonOpCodes::StringSlice, Some(args)) => {
147144
string_operators::string_slice(self, args.as_slice())
148-
.map(RadonTypes::from)
149-
.map_err(Into::into)
150-
}
145+
.map(RadonTypes::from)}
151146
(RadonOpCodes::StringSplit, Some(args)) => {
152147
string_operators::string_split(self, args.as_slice())
153-
.map(RadonTypes::from)
154-
.map_err(Into::into)
155-
}
148+
.map(RadonTypes::from)}
156149
(RadonOpCodes::StringToLowerCase, None) => {
157150
Ok(RadonTypes::from(string_operators::to_lowercase(self)))
158151
}

0 commit comments

Comments
 (0)