Skip to content

Commit 810b8db

Browse files
committed
Use AsRef instead of From for &str conversion
1 parent 2b0fa2f commit 810b8db

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

packages/vm/src/cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ where
290290
Ok(AnalysisReport {
291291
has_ibc_entry_points: REQUIRED_IBC_EXPORTS
292292
.iter()
293-
.all(|required| exports.contains(<&str>::from(required))),
293+
.all(|required| exports.contains(required.as_ref())),
294294
entrypoints,
295295
required_capabilities: required_capabilities_from_module(&module),
296296
})

packages/vm/src/static_analysis.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use std::collections::HashSet;
22

3-
use strum::{Display, EnumString, IntoStaticStr};
3+
use strum::{AsRefStr, Display, EnumString};
44
use wasmer::wasmparser::ExternalKind;
55

66
use crate::parsed_wasm::ParsedWasm;
77

88
/// An enum containing all available contract entrypoints.
99
/// This also provides conversions to and from strings.
10-
#[derive(PartialEq, Eq, Debug, Clone, Copy, Hash, EnumString, Display, IntoStaticStr)]
10+
#[derive(PartialEq, Eq, Debug, Clone, Copy, Hash, EnumString, Display, AsRefStr)]
1111
pub enum Entrypoint {
1212
#[strum(serialize = "instantiate")]
1313
Instantiate,
@@ -263,12 +263,10 @@ mod tests {
263263
fn entrypoint_to_string_works() {
264264
assert_eq!(
265265
Entrypoint::IbcPacketTimeout.to_string(),
266-
"ibc_packet_timeout".to_string()
266+
"ibc_packet_timeout"
267267
);
268268

269-
assert_eq!(
270-
<&'static str>::from(Entrypoint::IbcPacketReceive),
271-
"ibc_packet_receive"
272-
);
269+
let static_str: &'static str = Entrypoint::IbcPacketReceive.as_ref();
270+
assert_eq!(static_str, "ibc_packet_receive");
273271
}
274272
}

0 commit comments

Comments
 (0)