1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 22:00:03 -04:00

Add assert messages and print bad argument values in asserts (#5216)

Enabled the `missing_assert_message` lint

* [x] I have followed the instructions in the PR template

---------

Co-authored-by: Lucas Meurer <lucasmeurer96@gmail.com>
This commit is contained in:
Nicolas
2025-03-25 09:20:29 +01:00
committed by GitHub
parent 903bd81313
commit 58b2ac88c0
35 changed files with 331 additions and 108 deletions

View File

@@ -119,7 +119,7 @@ impl Mesh {
/// Panics when `other` mesh has a different texture.
pub fn append(&mut self, other: Self) {
profiling::function_scope!();
debug_assert!(other.is_valid());
debug_assert!(other.is_valid(), "Other mesh is invalid");
if self.is_empty() {
*self = other;
@@ -133,7 +133,7 @@ impl Mesh {
///
/// Panics when `other` mesh has a different texture.
pub fn append_ref(&mut self, other: &Self) {
debug_assert!(other.is_valid());
debug_assert!(other.is_valid(), "Other mesh is invalid");
if self.is_empty() {
self.texture_id = other.texture_id;
@@ -155,7 +155,10 @@ impl Mesh {
/// Panics when the mesh has assigned a texture.
#[inline(always)]
pub fn colored_vertex(&mut self, pos: Pos2, color: Color32) {
debug_assert!(self.texture_id == TextureId::default());
debug_assert!(
self.texture_id == TextureId::default(),
"Mesh has an assigned texture"
);
self.vertices.push(Vertex {
pos,
uv: WHITE_UV,
@@ -218,7 +221,10 @@ impl Mesh {
/// Uniformly colored rectangle.
#[inline(always)]
pub fn add_colored_rect(&mut self, rect: Rect, color: Color32) {
debug_assert!(self.texture_id == TextureId::default());
debug_assert!(
self.texture_id == TextureId::default(),
"Mesh has an assigned texture"
);
self.add_rect_with_uv(rect, [WHITE_UV, WHITE_UV].into(), color);
}
@@ -227,7 +233,7 @@ impl Mesh {
/// Splits this mesh into many smaller meshes (if needed)
/// where the smaller meshes have 16-bit indices.
pub fn split_to_u16(self) -> Vec<Mesh16> {
debug_assert!(self.is_valid());
debug_assert!(self.is_valid(), "Mesh is invalid");
const MAX_SIZE: u32 = u16::MAX as u32;
@@ -280,7 +286,7 @@ impl Mesh {
vertices: self.vertices[(min_vindex as usize)..=(max_vindex as usize)].to_vec(),
texture_id: self.texture_id,
};
debug_assert!(mesh.is_valid());
debug_assert!(mesh.is_valid(), "Mesh is invalid");
output.push(mesh);
}
output