1
Fork 0

Safe Transmute: Update definition of Condition type

- Change `Condition` to not contain `Answer`s but instead just contain other
  `Condition`s directly.
- Also improve error reporting for `DstHasStricterAlignment`
This commit is contained in:
Bryan Garza 2023-05-24 17:47:13 -07:00
parent 6266358237
commit d2164d5c9a
5 changed files with 39 additions and 33 deletions

View file

@ -29,10 +29,10 @@ pub enum Condition<R> {
IfTransmutable { src: R, dst: R },
/// `Src` is transmutable into `Dst`, if all of the enclosed requirements are met.
IfAll(Vec<Answer<R>>),
IfAll(Vec<Condition<R>>),
/// `Src` is transmutable into `Dst` if any of the enclosed requirements are met.
IfAny(Vec<Answer<R>>),
IfAny(Vec<Condition<R>>),
}
/// Answers: Why wasn't the source type transmutable into the destination type?
@ -49,7 +49,7 @@ pub enum Reason {
/// `Dst` is larger than `Src`, and the excess bytes were not exclusively uninitialized.
DstIsTooBig,
/// Src should have a stricter alignment than Dst, but it does not.
DstHasStricterAlignment,
DstHasStricterAlignment { src_min_align: usize, dst_min_align: usize },
/// Can't go from shared pointer to unique pointer
DstIsMoreUnique,
}