Safe Transmute: Refactor error handling and Answer type
- Create `Answer` type that is not just a type alias of `Result` - Remove a usage of `map_layouts` to make the code easier to read - Don't hide errors related to Unknown Layout when computing transmutability
This commit is contained in:
@@ -4,6 +4,8 @@ use crate::{layout, Reason};
|
||||
use itertools::Itertools;
|
||||
|
||||
mod bool {
|
||||
use crate::Answer;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
@@ -17,7 +19,7 @@ mod bool {
|
||||
UltraMinimal,
|
||||
)
|
||||
.answer();
|
||||
assert_eq!(answer, Ok(None));
|
||||
assert_eq!(answer, Answer::Yes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -30,7 +32,7 @@ mod bool {
|
||||
UltraMinimal,
|
||||
)
|
||||
.answer();
|
||||
assert_eq!(answer, Ok(None));
|
||||
assert_eq!(answer, Answer::Yes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -65,7 +67,7 @@ mod bool {
|
||||
|
||||
if src_set.is_subset(&dst_set) {
|
||||
assert_eq!(
|
||||
Ok(None),
|
||||
Answer::Yes,
|
||||
MaybeTransmutableQuery::new(
|
||||
src_layout.clone(),
|
||||
dst_layout.clone(),
|
||||
@@ -80,7 +82,7 @@ mod bool {
|
||||
);
|
||||
} else if !src_set.is_disjoint(&dst_set) {
|
||||
assert_eq!(
|
||||
Ok(None),
|
||||
Answer::Yes,
|
||||
MaybeTransmutableQuery::new(
|
||||
src_layout.clone(),
|
||||
dst_layout.clone(),
|
||||
@@ -95,7 +97,7 @@ mod bool {
|
||||
);
|
||||
} else {
|
||||
assert_eq!(
|
||||
Err(Reason::DstIsBitIncompatible),
|
||||
Answer::No(Reason::DstIsBitIncompatible),
|
||||
MaybeTransmutableQuery::new(
|
||||
src_layout.clone(),
|
||||
dst_layout.clone(),
|
||||
|
||||
Reference in New Issue
Block a user