Skip to content

Commit

Permalink
Move panic msg in static str
Browse files Browse the repository at this point in the history
  • Loading branch information
yannham committed Dec 1, 2022
1 parent 535f7bf commit 1e18dfb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/eval/lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ pub enum InnerThunkData {
},
}

const REVTHUNK_NO_CACHED_VALUE_MSG: &str =
"tried to get data from a revertible thunk without a cached value";

impl ThunkData {
/// Create new standard thunk data.
pub fn new(closure: Closure) -> Self {
Expand Down Expand Up @@ -234,9 +237,9 @@ impl ThunkData {
// them (build the cached value) in a second step. But calling to
// [`ThunkData::new_rev`] followed by [`ThunkData::build_cached_value`] should be logically
// seen as just one construction operation.
InnerThunkData::Revertible { ref cached, .. } => cached
.as_ref()
.expect("tried to get data from a revertible thunk without a cached value"),
InnerThunkData::Revertible { ref cached, .. } => {
cached.as_ref().expect(REVTHUNK_NO_CACHED_VALUE_MSG)
}
}
}

Expand Down Expand Up @@ -266,7 +269,7 @@ impl ThunkData {
// [`ThunkData::new_rev`] followed by [`ThunkData::build_cached_value`] should be logically
// seen as just one construction operation.
InnerThunkData::Revertible { cached, .. } => {
cached.expect("tried to get data from a revertible thunk without a cached value")
cached.expect(REVTHUNK_NO_CACHED_VALUE_MSG)
}
}
}
Expand Down

0 comments on commit 1e18dfb

Please sign in to comment.