Skip to content

Commit d155c48

Browse files
committed
Run clippy
1 parent 969841f commit d155c48

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

src/builder.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ thread_local! {
2222
pub(crate) fn thread_add_script(id: u64, script: StructuredScript) {
2323
SCRIPT_MAP.with(|script_map| {
2424
let mut map = script_map.write().unwrap();
25-
if !map.contains_key(&id) {
26-
map.insert(id, Box::new(script));
27-
}
25+
map.entry(id).or_insert_with(|| Box::new(script));
2826
});
2927
}
3028

@@ -119,7 +117,7 @@ impl StructuredScript {
119117
}
120118

121119
pub fn has_stack_hint(&self) -> bool {
122-
self.stack_hint != None
120+
self.stack_hint.is_some()
123121
}
124122

125123
pub fn num_unclosed_ifs(&self) -> i32 {
@@ -401,8 +399,8 @@ impl StructuredScript {
401399
match &self.stack_hint {
402400
Some(x) => x.clone(),
403401
None => {
404-
let stack_status = analyzer.analyze_status(self);
405-
stack_status
402+
403+
analyzer.analyze_status(self)
406404
}
407405
}
408406
}

src/chunker.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl UndoInfo {
101101
return true;
102102
}
103103
}
104-
return false;
104+
false
105105
}
106106
}
107107

@@ -318,10 +318,12 @@ impl Chunker {
318318
.try_into()
319319
.expect("Consuming more stack elements than there are on the stack 3"),
320320
altstack_input_size: input_altstack_size,
321-
altstack_output_size: status.altstack_changed.try_into().expect(&format!(
322-
"Consuming more stack elements than there are on the altstack: {:?}",
323-
status
324-
)),
321+
altstack_output_size: status.altstack_changed.try_into().unwrap_or_else(|_| {
322+
panic!(
323+
"Consuming more stack elements than there are on the altstack: {:?}",
324+
status
325+
)
326+
}),
325327
};
326328

327329
Chunk::new(chunk_scripts, chunk_len, chunk_stats, last_constant)

tests/test_analyzer.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn inner_fn2() -> Script {
6565

6666
#[test]
6767
fn test_inner1() {
68-
let mut script = inner_fn1();
68+
let script = inner_fn1();
6969
let mut analyzer = StackAnalyzer::new();
7070
let status = script.get_stack(&mut analyzer);
7171
assert_eq!(
@@ -76,7 +76,7 @@ fn test_inner1() {
7676

7777
#[test]
7878
fn test_deepthest() {
79-
let mut script = script! (
79+
let script = script! (
8080
{inner_fn1()}
8181
{inner_fn1()}
8282
OP_ADD
@@ -88,7 +88,7 @@ fn test_deepthest() {
8888
[-12, -3]
8989
);
9090

91-
let mut script = script!(
91+
let script = script!(
9292
{ inner_fn2() }
9393
{ inner_fn2() }
9494
OP_ADD
@@ -103,7 +103,7 @@ fn test_deepthest() {
103103

104104
#[test]
105105
fn test_deepthest2() {
106-
let mut script = script! (
106+
let script = script! (
107107
{1}
108108
OP_IF
109109
{ 120 }
@@ -120,7 +120,7 @@ fn test_deepthest2() {
120120

121121
#[test]
122122
fn test_altstack() {
123-
let mut script = script! (
123+
let script = script! (
124124
OP_FROMALTSTACK
125125
OP_FROMALTSTACK
126126
OP_FROMALTSTACK
@@ -137,7 +137,7 @@ fn test_altstack() {
137137
}
138138
);
139139

140-
let mut script = script!(
140+
let script = script!(
141141
OP_TOALTSTACK
142142
OP_TOALTSTACK
143143
OP_TOALTSTACK
@@ -157,7 +157,7 @@ fn test_altstack() {
157157

158158
#[test]
159159
fn test_altstack_and_opif() {
160-
let mut script = script! (
160+
let script = script! (
161161
OP_IF
162162
OP_FROMALTSTACK
163163
OP_SUB

tests/test_chunker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use bitcoin::{opcodes::all::{OP_FROMALTSTACK, OP_TOALTSTACK}, ScriptBuf};
2-
use bitcoin_script::{chunker::ChunkStats, script, Chunker};
1+
use bitcoin::ScriptBuf;
2+
use bitcoin_script::{script, Chunker};
33

44
#[test]
55
fn test_chunker_simple() {

0 commit comments

Comments
 (0)