mirror of
https://github.com/hannobraun/Fornjot
synced 2025-06-10 12:01:38 +00:00
use built-in 'assert'
This commit is contained in:
parent
392a2d34ef
commit
844185baf5
@ -46,9 +46,10 @@ where
|
||||
}
|
||||
|
||||
// We know that `self != other`, or we wouldn't have made it here.
|
||||
if self.is_some() && other.is_some() {
|
||||
panic!("Can't merge two `Option`s that are both `Some`")
|
||||
}
|
||||
assert!(
|
||||
self.is_none() || other.is_none(),
|
||||
"Can't merge two `Option`s that are both `Some`"
|
||||
);
|
||||
|
||||
self.xor(other)
|
||||
}
|
||||
|
@ -94,9 +94,7 @@ impl<T> Block<T> {
|
||||
pub fn insert(&mut self, index: ObjectIndex, object: T) {
|
||||
let slot = &mut self.objects[index.0];
|
||||
|
||||
if slot.is_some() {
|
||||
panic!("Attempting to overwrite object in store")
|
||||
}
|
||||
assert!(slot.is_none(), "Attempting to overwrite object in store");
|
||||
|
||||
*slot = Some(object);
|
||||
}
|
||||
|
@ -21,9 +21,10 @@ impl<const D: usize> Line<D> {
|
||||
origin: Point<D>,
|
||||
direction: Vector<D>,
|
||||
) -> Self {
|
||||
if direction.magnitude() == Scalar::ZERO {
|
||||
panic!("Can't construct `Line`. Direction is zero: {direction:?}");
|
||||
}
|
||||
assert!(
|
||||
direction.magnitude() != Scalar::ZERO,
|
||||
"Can't construct `Line`. Direction is zero: {direction:?}"
|
||||
);
|
||||
|
||||
Self { origin, direction }
|
||||
}
|
||||
|
@ -45,9 +45,10 @@ impl EventLoopHandler {
|
||||
let event = events
|
||||
.try_recv()
|
||||
.map_err(|err| {
|
||||
if err.is_disconnected() {
|
||||
panic!("Expected channel to never disconnect");
|
||||
}
|
||||
assert!(
|
||||
!err.is_disconnected(),
|
||||
"Expected channel to never disconnect"
|
||||
);
|
||||
})
|
||||
.ok();
|
||||
|
||||
|
@ -9,7 +9,7 @@ pub fn find_version_in_str(s: &str) -> anyhow::Result<Option<semver::Version>> {
|
||||
version.as_str(),
|
||||
);
|
||||
})
|
||||
.filter_map(|m| {
|
||||
.find_map(|m| {
|
||||
let version = semver::Version::parse(m.as_str()).ok();
|
||||
|
||||
if version.is_some() {
|
||||
@ -19,8 +19,7 @@ pub fn find_version_in_str(s: &str) -> anyhow::Result<Option<semver::Version>> {
|
||||
}
|
||||
|
||||
version
|
||||
})
|
||||
.next();
|
||||
});
|
||||
|
||||
Ok(version)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user