Skip to content

Commit 863429f

Browse files
authored
Merge pull request stacks-network#6480 from Jiloc/fix/remove-duplicate-CostOverflowingMath
Fix:remove duplicated `CostOverflowingMath` trait
2 parents d966da5 + 26afd25 commit 863429f

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

clarity/src/vm/costs/mod.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::collections::HashMap;
1818
use std::{cmp, fmt};
1919

2020
pub use clarity_serialization::errors::CostErrors;
21-
pub use clarity_serialization::execution_cost::ExecutionCost;
21+
pub use clarity_serialization::execution_cost::{CostOverflowingMath, ExecutionCost};
2222
use costs_1::Costs1;
2323
use costs_2::Costs2;
2424
use costs_2_testnet::Costs2Testnet;
@@ -1253,28 +1253,6 @@ impl CostTracker for &mut LimitedCostTracker {
12531253
}
12541254
}
12551255

1256-
pub trait CostOverflowingMath<T> {
1257-
fn cost_overflow_mul(self, other: T) -> Result<T>;
1258-
fn cost_overflow_add(self, other: T) -> Result<T>;
1259-
fn cost_overflow_sub(self, other: T) -> Result<T>;
1260-
fn cost_overflow_div(self, other: T) -> Result<T>;
1261-
}
1262-
1263-
impl CostOverflowingMath<u64> for u64 {
1264-
fn cost_overflow_mul(self, other: u64) -> Result<u64> {
1265-
self.checked_mul(other).ok_or(CostErrors::CostOverflow)
1266-
}
1267-
fn cost_overflow_add(self, other: u64) -> Result<u64> {
1268-
self.checked_add(other).ok_or(CostErrors::CostOverflow)
1269-
}
1270-
fn cost_overflow_sub(self, other: u64) -> Result<u64> {
1271-
self.checked_sub(other).ok_or(CostErrors::CostOverflow)
1272-
}
1273-
fn cost_overflow_div(self, other: u64) -> Result<u64> {
1274-
self.checked_div(other).ok_or(CostErrors::CostOverflow)
1275-
}
1276-
}
1277-
12781256
// ONLY WORKS IF INPUT IS u64
12791257
fn int_log2(input: u64) -> Option<u64> {
12801258
63_u32.checked_sub(input.leading_zeros()).map(|floor_log| {

0 commit comments

Comments
 (0)