Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0ef34db

Browse files
committed
feat(rad): optimize string methods, add guards and tests
1 parent7d88dce commit0ef34db

File tree

6 files changed

+656
-328
lines changed

6 files changed

+656
-328
lines changed

‎rad/src/operators/bytes.rs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::convert::TryFrom;
55
usecrate::{
66
error::RadError,
77
hash_functions::{self,RadonHashFunctions},
8-
operators,
8+
operators::decode_single_arg,
99
types::{
1010
RadonType,
1111
bytes::{RadonBytes,RadonBytesEncoding,RadonBytesEndianness},
@@ -86,10 +86,8 @@ pub fn slice(input: &RadonBytes, args: &[Value]) -> Result<RadonBytes, RadError>
8686
}
8787

8888
pubfnto_integer(input:&RadonBytes,args:&Option<Vec<Value>>) ->Result<RadonInteger,RadError>{
89-
let endianness = operators::decode_single_arg::<RadonBytes,u8,RadonBytesEndianness,_,_>(
90-
args,
91-
"ToInteger",
92-
)?;
89+
let endianness =
90+
decode_single_arg::<RadonBytes,u8,RadonBytesEndianness,_,_>(args,0,"ToInteger")?;
9391

9492
match input.value().len(){
9593
// There is nothing to decode if the input is empty
@@ -122,11 +120,13 @@ pub fn to_string_legacy(input: &RadonBytes) -> Result<RadonString, RadError> {
122120

123121
pubfnto_string(input:&RadonBytes,args:&Option<Vec<Value>>) ->Result<RadonString,RadError>{
124122
let bytes_encoding =
125-
operators::decode_single_arg::<RadonBytes,u8,RadonBytesEncoding,_,_>(args,"ToString")?;
123+
decode_single_arg::<RadonBytes,u8,RadonBytesEncoding,_,_>(args,0,"ToString")?;
126124

127125
match bytes_encoding{
128126
RadonBytesEncoding::Hex =>RadonString::try_from(Value::Text(hex::encode(input.value()))),
129-
RadonBytesEncoding::Base58 =>RadonString::try_from(Value::Text(bs58::encode(input.value()).into_string())),
127+
RadonBytesEncoding::Base58 =>{
128+
RadonString::try_from(Value::Text(bs58::encode(input.value()).into_string()))
129+
}
130130
RadonBytesEncoding::Base64 =>RadonString::try_from(Value::Text(
131131
base64::engine::general_purpose::STANDARD.encode(input.value()),
132132
)),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp