Clean up some macro syntax

This commit is contained in:
Emil Ernerfeldt 2021-10-02 21:08:00 +02:00
parent f0868c2f07
commit f59abd9684
6 changed files with 13 additions and 13 deletions

View file

@ -425,7 +425,7 @@ pub fn warn_if_debug_build(ui: &mut crate::Ui) {
/// ```
#[macro_export]
macro_rules! github_link_file_line {
($github_url:expr, $label:expr) => {{
($github_url: expr, $label: expr) => {{
let url = format!("{}{}#L{}", $github_url, file!(), line!());
$crate::Hyperlink::new(url).text($label)
}};
@ -439,7 +439,7 @@ macro_rules! github_link_file_line {
/// ```
#[macro_export]
macro_rules! github_link_file {
($github_url:expr, $label:expr) => {{
($github_url: expr, $label: expr) => {{
let url = format!("{}{}", $github_url, file!());
$crate::Hyperlink::new(url).text($label)
}};
@ -462,10 +462,10 @@ macro_rules! github_link_file {
/// ```
#[macro_export]
macro_rules! trace {
($ui:expr) => {{
($ui: expr) => {{
$ui.trace_location(format!("{}:{}", file!(), line!()))
}};
($ui:expr, $label:expr) => {{
($ui: expr, $label: expr) => {{
$ui.trace_location(format!("{} - {}:{}", $label, file!(), line!()))
}};
}
@ -476,7 +476,7 @@ macro_rules! trace {
/// or with the `debug_egui_assert` feature in debug builds.
#[macro_export]
macro_rules! egui_assert {
($($arg:tt)*) => {
($($arg: tt)*) => {
if cfg!(any(
feature = "extra_asserts",
all(feature = "extra_debug_asserts", debug_assertions),

View file

@ -92,7 +92,7 @@ macro_rules! __egui_github_link_file {
() => {
crate::__egui_github_link_file!("(source code)")
};
($label:expr) => {
($label: expr) => {
egui::github_link_file!("https://github.com/emilk/egui/blob/master/", $label).small()
};
}
@ -104,7 +104,7 @@ macro_rules! __egui_github_link_file_line {
() => {
crate::__egui_github_link_file_line!("(source code)")
};
($label:expr) => {
($label: expr) => {
egui::github_link_file_line!("https://github.com/emilk/egui/blob/master/", $label).small()
};
}

View file

@ -340,7 +340,7 @@ pub fn normalized_angle(mut angle: f32) -> f32 {
#[test]
fn test_normalized_angle() {
macro_rules! almost_eq {
($left:expr, $right:expr) => {
($left: expr, $right: expr) => {
let left = $left;
let right = $right;
assert!((left - right).abs() < 1e-6, "{} != {}", left, right);
@ -362,7 +362,7 @@ fn test_normalized_angle() {
/// or with the `debug_egui_assert` feature in debug builds.
#[macro_export]
macro_rules! emath_assert {
($($arg:tt)*) => {
($($arg: tt)*) => {
if cfg!(any(
feature = "extra_asserts",
all(feature = "extra_debug_asserts", debug_assertions),

View file

@ -15,7 +15,7 @@ pub trait Numeric: Clone + Copy + PartialEq + PartialOrd + 'static {
}
macro_rules! impl_numeric_float {
($t:ident) => {
($t: ident) => {
impl Numeric for $t {
const INTEGRAL: bool = false;
const MIN: Self = std::$t::MIN;
@ -35,7 +35,7 @@ macro_rules! impl_numeric_float {
}
macro_rules! impl_numeric_integer {
($t:ident) => {
($t: ident) => {
impl Numeric for $t {
const INTEGRAL: bool = true;
const MIN: Self = std::$t::MIN;

View file

@ -423,7 +423,7 @@ impl std::fmt::Debug for Vec2 {
#[test]
fn test_vec2() {
macro_rules! almost_eq {
($left:expr, $right:expr) => {
($left: expr, $right: expr) => {
let left = $left;
let right = $right;
assert!((left - right).abs() < 1e-6, "{} != {}", left, right);

View file

@ -157,7 +157,7 @@ pub struct ClippedMesh(
/// or with the `debug_egui_assert` feature in debug builds.
#[macro_export]
macro_rules! epaint_assert {
($($arg:tt)*) => {
($($arg: tt)*) => {
if cfg!(any(
feature = "extra_asserts",
all(feature = "extra_debug_asserts", debug_assertions),