Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Commit

Permalink
Remove some extraneous .to_string()s
Browse files Browse the repository at this point in the history
Holy cow, there are so many occurences!
I gave up after removing many.
  • Loading branch information
timotree3 committed Oct 21, 2019
1 parent e0aa8ec commit eb018f0
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 51 deletions.
12 changes: 6 additions & 6 deletions app_spec/zomes/blog/code/src/blog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub fn handle_check_sum(num1: u32, num2: u32) -> ZomeApiResult<u32> {
let call_json = hdk::call(
hdk::THIS_INSTANCE,
"summer",
Address::from(PUBLIC_TOKEN.to_string()),
Address::from(PUBLIC_TOKEN),
"sum",
check_sum_args(num1, num2).into(),
)?;
Expand Down Expand Up @@ -228,7 +228,7 @@ pub fn handle_receive(from: Address, json_msg: JsonString) -> String {
Err(err) => format!("error: {}", err),
Ok(message) => match message.msg_type.as_str() {
// ping simply returns the body of the message
"ping" => format!("got {} from {}", message.body.to_string(), from),
"ping" => format!("got {} from {}", message.body, from),

// post calls the create_post zome function handler after checking the supplied signature
"post" => {
Expand Down Expand Up @@ -324,7 +324,7 @@ pub fn handle_create_post_with_claim(

let response = hdk::send(grantor, JsonString::from(message).into(), 10000.into())?;
let response_message: Message = JsonString::from_json(&response).try_into()?;
Ok(Address::from(response_message.body.to_string()))
Ok(Address::from(response_message.body))
}

pub fn handle_memo_address(content: String) -> ZomeApiResult<Address> {
Expand Down Expand Up @@ -527,8 +527,8 @@ pub fn handle_recommend_post(
post_address: Address,
agent_address: Address,
) -> ZomeApiResult<Address> {
hdk::debug(format!("my address:\n{:?}", AGENT_ADDRESS.to_string()))?;
hdk::debug(format!("other address:\n{:?}", agent_address.to_string()))?;
hdk::debug(format!("my address:\n{:?}", AGENT_ADDRESS))?;
hdk::debug(format!("other address:\n{:?}", agent_address))?;
hdk::link_entries(&agent_address, &post_address, "recommended_posts", "")
}

Expand All @@ -541,7 +541,7 @@ pub fn handle_get_post_bridged(post_address: Address) -> ZomeApiResult<Option<En
let raw_json = hdk::call(
"test-bridge",
"blog",
Address::from(PUBLIC_TOKEN.to_string()),
Address::from(PUBLIC_TOKEN),
"get_post",
json!({
"post_address": post_address,
Expand Down
4 changes: 2 additions & 2 deletions app_spec/zomes/blog/code/src/memo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ mod tests {
let date_created = "bar";
let memo = Memo::new(content, date_created);

assert_eq!(content.to_string(), memo.content(),);
assert_eq!(content, memo.content(),);

assert_eq!(date_created.to_string(), memo.date_created(),);
assert_eq!(date_created, memo.date_created(),);
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions app_spec/zomes/blog/code/src/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ mod tests {
let date_created = "bar";
let post = Post::new(content, date_created);

assert_eq!(content.to_string(), post.content(),);
assert_eq!(content, post.content(),);

assert_eq!(date_created.to_string(), post.date_created(),);
assert_eq!(date_created, post.date_created(),);
}

#[test]
Expand Down
12 changes: 6 additions & 6 deletions app_spec_proc_macro/zomes/blog/code/src/blog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub fn handle_check_sum(num1: u32, num2: u32) -> ZomeApiResult<u32> {
let call_json = hdk::call(
hdk::THIS_INSTANCE,
"summer",
Address::from(PUBLIC_TOKEN.to_string()),
Address::from(PUBLIC_TOKEN),
"sum",
check_sum_args(num1, num2).into(),
)?;
Expand Down Expand Up @@ -228,7 +228,7 @@ pub fn handle_receive(from: Address, json_msg: JsonString) -> String {
Err(err) => format!("error: {}", err),
Ok(message) => match message.msg_type.as_str() {
// ping simply returns the body of the message
"ping" => format!("got {} from {}", message.body.to_string(), from),
"ping" => format!("got {} from {}", message.body, from),

// post calls the create_post zome function handler after checking the supplied signature
"post" => {
Expand Down Expand Up @@ -324,7 +324,7 @@ pub fn handle_create_post_with_claim(

let response = hdk::send(grantor, JsonString::from(message).into(), 10000.into())?;
let response_message: Message = JsonString::from_json(&response).try_into()?;
Ok(Address::from(response_message.body.to_string()))
Ok(Address::from(response_message.body))
}

pub fn handle_memo_address(content: String) -> ZomeApiResult<Address> {
Expand Down Expand Up @@ -523,8 +523,8 @@ pub fn handle_recommend_post(
post_address: Address,
agent_address: Address,
) -> ZomeApiResult<Address> {
hdk::debug(format!("my address:\n{:?}", AGENT_ADDRESS.to_string()))?;
hdk::debug(format!("other address:\n{:?}", agent_address.to_string()))?;
hdk::debug(format!("my address:\n{:?}", AGENT_ADDRESS))?;
hdk::debug(format!("other address:\n{:?}", agent_address))?;
hdk::link_entries(&agent_address, &post_address, "recommended_posts", "")
}

Expand All @@ -537,7 +537,7 @@ pub fn handle_get_post_bridged(post_address: Address) -> ZomeApiResult<Option<En
let raw_json = hdk::call(
"test-bridge",
"blog",
Address::from(PUBLIC_TOKEN.to_string()),
Address::from(PUBLIC_TOKEN),
"get_post",
json!({
"post_address": post_address,
Expand Down
4 changes: 2 additions & 2 deletions app_spec_proc_macro/zomes/blog/code/src/memo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ mod tests {
let date_created = "bar";
let memo = Memo::new(content, date_created);

assert_eq!(content.to_string(), memo.content(),);
assert_eq!(content, memo.content(),);

assert_eq!(date_created.to_string(), memo.date_created(),);
assert_eq!(date_created, memo.date_created(),);
}

#[test]
Expand Down
6 changes: 3 additions & 3 deletions app_spec_proc_macro/zomes/blog/code/src/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ mod tests {
let date_created = "bar";
let post = Post::new(content, date_created);

assert_eq!(content.to_string(), post.content(),);
assert_eq!(content, post.content(),);

assert_eq!(date_created.to_string(), post.date_created(),);
assert_eq!(date_created, post.date_created(),);
}

#[test]
Expand Down Expand Up @@ -209,7 +209,7 @@ mod tests {
entry,
validation_data
}),
Err("Content too long".to_string()),
Err("Content too long"),
);

let post_definition_link = post_definition.links.first().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/cli/chain_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn chain_log(storage_path: Option<PathBuf>, instance_id: String) -> DefaultR
format_err!(
"Could not display chain for '{}': {}",
cas_path.to_string_lossy(),
err.to_string()
err
)
})?;

Expand Down
1 change: 0 additions & 1 deletion crates/cli/src/cli/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pub fn generate(zome_name: &Path, language: &str) -> DefaultResult<()> {
let zome_name_string = zome_name
.to_str()
.expect("Invalid zome path given")
.to_string()
.replace("/", "_")
.replace("zomes_", "");

Expand Down
4 changes: 2 additions & 2 deletions crates/conductor_lib/src/conductor/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ impl Conductor {
StorageConfiguration::File { path } => {
context_builder =
context_builder.with_file_storage(path).map_err(|hc_err| {
format!("Error creating context: {}", hc_err.to_string())
format!("Error creating context: {}", hc_err)
})?
}
StorageConfiguration::Memory => {
Expand All @@ -784,7 +784,7 @@ impl Conductor {
context_builder
.with_pickle_storage(path)
.map_err(|hc_err| {
format!("Error creating context: {}", hc_err.to_string())
format!("Error creating context: {}", hc_err)
})?
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/conductor_lib/src/conductor/broadcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Broadcaster {
Broadcaster::Ws(sender) => sender
.send(ws::Message::Text(msg.into().to_string()))
.map_err(|e| {
HolochainError::ErrorGeneric(format!("Broadcaster::Ws -- {}", e.to_string()))
HolochainError::ErrorGeneric(format!("Broadcaster::Ws -- {}", e))
})?,
Broadcaster::Noop => (),
}
Expand Down
2 changes: 1 addition & 1 deletion crates/conductor_lib/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ where
T: Deserialize<'a>,
{
toml::from_str::<T>(toml).map_err(|e| {
HolochainError::IoError(format!("Error loading configuration: {}", e.to_string()))
HolochainError::IoError(format!("Error loading configuration: {}", e))
})
}

Expand Down
12 changes: 6 additions & 6 deletions crates/core/src/link_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pub mod tests {

pub fn create_example_link() -> Link {
Link::new(
&Address::from("12".to_string()),
&Address::from("34".to_string()),
&Address::from("12"),
&Address::from("34"),
"fake",
"fake-tag",
)
Expand All @@ -30,17 +30,17 @@ pub mod tests {

pub fn create_test_link_b() -> Link {
Link::new(
&Address::from("56".to_string()),
&Address::from("78".to_string()),
&Address::from("56"),
&Address::from("78"),
"faux",
"fake-tag",
)
}

pub fn create_test_link_c() -> Link {
Link::new(
&Address::from("90".to_string()),
&Address::from("ab".to_string()),
&Address::from("90"),
&Address::from("ab"),
"fake",
"fake-tag",
)
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/nucleus/ribosome/api/emit_signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub mod tests {
let context = Arc::new(context);

let args_string: JsonString = test_args().into();
println!("{}", args_string.to_string());
println!("{}", args_string);

let _ = test_zome_api_function_call(context.clone(), test_args_bytes());

Expand Down
2 changes: 1 addition & 1 deletion crates/core_types/src/chain_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub mod tests {
}

pub fn test_header_address() -> Address {
Address::from("Qmc1n5gbUU2QKW6is9ENTqmaTcEjYMBwNkcACCxe3bBDnd".to_string())
Address::from("Qmc1n5gbUU2QKW6is9ENTqmaTcEjYMBwNkcACCxe3bBDnd")
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/core_types/src/entry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub fn expected_serialized_entry_content() -> JsonString {
/// the correct address for test_entry()
#[cfg_attr(tarpaulin, skip)]
pub fn expected_entry_address() -> Address {
Address::from("Qma6RfzvZRL127UCEVEktPhQ7YSS1inxEFw7SjEsfMJcrq".to_string())
Address::from("Qma6RfzvZRL127UCEVEktPhQ7YSS1inxEFw7SjEsfMJcrq")
}

/// dummy entry, same as test_entry()
Expand Down
4 changes: 2 additions & 2 deletions crates/core_types/src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,13 @@ impl From<SerdeError> for HolochainError {

impl From<base64::DecodeError> for HolochainError {
fn from(error: base64::DecodeError) -> Self {
HolochainError::ErrorGeneric(format!("base64 decode error: {}", error.to_string()))
HolochainError::ErrorGeneric(format!("base64 decode error: {}", error))
}
}

impl From<std::str::Utf8Error> for HolochainError {
fn from(error: std::str::Utf8Error) -> Self {
HolochainError::ErrorGeneric(format!("std::str::Utf8Error error: {}", error.to_string()))
HolochainError::ErrorGeneric(format!("std::str::Utf8Error error: {}", error))
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/dpki/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ mod tests {
assert_eq!(0, decrypted_data.compare(&mut random_data));

// totally bogus data will return an error
let bogus_encrypted_data = "askdfklasjdasldkfjlkasdjflkasdjfasdf".to_string();
let bogus_encrypted_data = "askdfklasjdasldkfjlkasdjflkasdjfasdf";
let decrypted_result = decrypt_with_passphrase_buf(
&bogus_encrypted_data,
&mut random_passphrase,
Expand Down
2 changes: 1 addition & 1 deletion crates/hdk/tests/links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ pub fn test_links_with_load() {
);
println!("got first links");
let expected_links = expected_result.expect("Could not get links for test");
assert_eq!(expected_links[0].stuff, "message me".to_string());
assert_eq!(expected_links[0].stuff, "message me");

let result = make_test_call(
&mut hc,
Expand Down
12 changes: 6 additions & 6 deletions crates/hdk/wasm-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub extern "C" fn check_commit_entry(
let entry: Entry = match load_ribosome_encoded_json(encoded_allocation_of_input) {
Ok(entry) => entry,
Err(hc_err) => {
hdk::debug(format!("ERROR: {:?}", hc_err.to_string())).ok();
hdk::debug(format!("ERROR: {:?}", hc_err)).ok();
return RibosomeEncodedValue::Failure(RibosomeErrorCode::ArgumentDeserializationFailed)
.into();
}
Expand Down Expand Up @@ -497,7 +497,7 @@ fn handle_check_call() -> ZomeApiResult<JsonString> {
let maybe_hash = hdk::call(
hdk::THIS_INSTANCE,
"test_zome",
Address::from(hdk::PUBLIC_TOKEN.to_string()),
Address::from(hdk::PUBLIC_TOKEN),
"check_app_entry_address",
empty_dumpty,
);
Expand All @@ -515,7 +515,7 @@ fn handle_check_call_with_args() -> ZomeApiResult<JsonString> {
hdk::call(
hdk::THIS_INSTANCE,
"test_zome",
Address::from(hdk::PUBLIC_TOKEN.to_string()),
Address::from(hdk::PUBLIC_TOKEN),
"check_commit_entry_macro",
JsonString::from(CommitEntryInput {
entry: hdk_test_entry(),
Expand Down Expand Up @@ -888,7 +888,7 @@ define_zome! {
let _call_result = hdk::call(
hdk::THIS_INSTANCE,
"test_zome",
Address::from(hdk::PUBLIC_TOKEN.to_string()),
Address::from(hdk::PUBLIC_TOKEN),
"check_app_entry_address",
JsonString::empty_object(),
)?;
Expand All @@ -910,8 +910,8 @@ define_zome! {
.into(),
);
match hdk::commit_entry(&entry) {
Ok(address) => format!("Committed: '{}' / address: {}", payload, address.to_string()),
Err(error) => format!("Error committing in receive: '{}'", error.to_string()),
Ok(address) => format!("Committed: '{}' / address: {}", payload, address),
Err(error) => format!("Error committing in receive: '{}'", error),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/net/src/connection/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<'a> From<&'a NamedBinaryData> for Protocol {
Protocol::NamedBinary(sub)
}
b"json" => Protocol::Json(JsonString::from_json(
&String::from_utf8_lossy(&nb.data).to_string(),
&String::from_utf8_lossy(&nb.data),
)),
b"ping" => {
let sub: PingData = rmp_serde::from_slice(&nb.data).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions crates/net/src/ipc_net_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ impl IpcNetWorker {
.as_object()
.unwrap()
.iter()
.map(|(k, v)| (k.to_string(), v.as_str().unwrap().to_string().into()))
.map(|(k, v)| (k.to_string(), v.as_str().unwrap().into()))
.collect();
// create a new IpcNetWorker witch spawns the n3h process
return IpcNetWorker::priv_new_with_spawn(
handler,
spawn_config["workDir"].as_str().unwrap().to_string().into(),
spawn_config["workDir"].as_str().unwrap().into(),
enduser_config,
env,
bootstrap_nodes,
Expand Down
4 changes: 2 additions & 2 deletions crates/wasm_utils/wasm-test/integration-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ pub extern "C" fn round_trip_foo(_: RibosomeEncodingBits) -> RibosomeEncodingBit
MemoryInt::from(allocation.length()),
);
assert_eq!(
"foo".to_string(),
"foo",
allocation.read_to_string(),
);

Expand Down Expand Up @@ -263,7 +263,7 @@ pub extern "C" fn round_trip_foo(_: RibosomeEncodingBits) -> RibosomeEncodingBit
MemoryInt::from(allocation2.length()),
);
assert_eq!(
"barz".to_string(),
"barz",
allocation2.read_to_string(),
);

Expand Down

0 comments on commit eb018f0

Please sign in to comment.