From be8def963956c605bca28bcd8df673bd7ec3740b Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Wed, 15 May 2024 02:09:54 -0400 Subject: [PATCH] feat(layout)!: Use *= instead of =* (#45) This is a follow up to https://github.com/ratatui-org/ratatui-macros/pull/34 `*=` is more consistent with the other symbols, e.g. `<=`, `>=`. It is also more in line with what other programming languages do. ``` $ python Python 3.10.13 | packaged by conda-forge | (main, Oct 26 2023, 18:09:17) [Clang 16.0.6 ] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> x = 1 >>> x *= 2 >>> x 2 ``` `=*` throws an error. ``` >>> x =* 2 File "", line 1 SyntaxError: can't use starred expression here >>> ``` --- .rustfmt.toml | 2 ++ README.md | 2 +- src/layout.rs | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 .rustfmt.toml diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..b7d70c3 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,2 @@ +format_macro_bodies = true +format_macro_matchers = true diff --git a/README.md b/README.md index bad283c..9f08d4b 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ use ratatui::prelude::*; use ratatui_macros::constraints; assert_eq!( - constraints![==50, ==30%, >=3, <=1, ==1/2, =*1], + constraints![==50, ==30%, >=3, <=1, ==1/2, *=1], [ Constraint::Length(50), Constraint::Percentage(30), diff --git a/src/layout.rs b/src/layout.rs index 14aa4d4..7b3c424 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -13,7 +13,7 @@ /// assert_eq!(constraint!(== 1 / 3), Constraint::Ratio(1, 3)); /// assert_eq!(constraint!(== 3), Constraint::Length(3)); /// assert_eq!(constraint!(== 10 %), Constraint::Percentage(10)); -/// assert_eq!(constraint!(=* 1), Constraint::Fill(1)); +/// assert_eq!(constraint!(*= 1), Constraint::Fill(1)); /// ``` #[macro_export] macro_rules! constraint { @@ -32,7 +32,7 @@ macro_rules! constraint { (== $expr:expr) => { ratatui::layout::Constraint::Length($expr) }; - (=* $expr:expr) => { + (*= $expr:expr) => { ratatui::layout::Constraint::Fill($expr) }; } @@ -56,7 +56,7 @@ macro_rules! constraint { /// use ratatui::prelude::*; /// use ratatui_macros::constraints; /// assert_eq!( -/// constraints![==50, ==30%, >=3, <=1, ==1/2, =*1], +/// constraints![==50, ==30%, >=3, <=1, ==1/2, *=1], /// [ /// Constraint::Length(50), /// Constraint::Percentage(30),