mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-16 13:48:26 +00:00
Remove deprecated macros: inline_props, format_args_f!, render! (#2574)
* remove deprecated macros * Rename derive_typed_builder
This commit is contained in:
parent
7f6f0de085
commit
2c20d3dc5e
5 changed files with 5 additions and 97 deletions
|
@ -183,7 +183,7 @@ fn app() -> Element {
|
|||
// Can take children too!
|
||||
Taller { a: "asd", div {"hello world!"} }
|
||||
|
||||
// This component's props are defined *inline* with the `inline_props` macro
|
||||
// This component's props are defined *inline* with the `component` macro
|
||||
WithInline { text: "using functionc all syntax" }
|
||||
|
||||
// Components can be generic too
|
||||
|
@ -193,7 +193,7 @@ fn app() -> Element {
|
|||
// Type inference can be used too
|
||||
TypedInput { initial: 10.0 }
|
||||
|
||||
// generic with the `inline_props` macro
|
||||
// generic with the `component` macro
|
||||
Label { text: "hello generic world!" }
|
||||
Label { text: 99.9 }
|
||||
|
||||
|
|
|
@ -13,24 +13,9 @@ mod utils;
|
|||
|
||||
use dioxus_rsx as rsx;
|
||||
|
||||
/// Format a string with inline rust expressions. [`format_args_f!`] is very similar to [`format_args`], but it allows you to use arbitrary rust expressions inside braces instead of just variables:
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// # use dioxus::prelude::*;
|
||||
/// let formatted_with_variables = format_args!("{} + {} = {}", 1, 2, 1 + 2);
|
||||
/// let formatted_with_inline_expressions = format_args_f!("{1} + {2} = {1 + 2}");
|
||||
/// ```
|
||||
#[proc_macro]
|
||||
pub fn format_args_f(input: TokenStream) -> TokenStream {
|
||||
use rsx::*;
|
||||
format_args_f_impl(parse_macro_input!(input as IfmtInput))
|
||||
.unwrap_or_else(|err| err.to_compile_error())
|
||||
.into()
|
||||
}
|
||||
|
||||
#[doc = include_str!("../docs/props.md")]
|
||||
#[proc_macro_derive(Props, attributes(props))]
|
||||
pub fn derive_typed_builder(input: TokenStream) -> TokenStream {
|
||||
pub fn derive_props(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as syn::DeriveInput);
|
||||
match props::impl_my_derive(&input) {
|
||||
Ok(output) => output.into(),
|
||||
|
@ -47,13 +32,6 @@ pub fn rsx(tokens: TokenStream) -> TokenStream {
|
|||
}
|
||||
}
|
||||
|
||||
/// The rsx! macro makes it easy for developers to write jsx-style markup in their components.
|
||||
#[deprecated(note = "Use `rsx!` instead.")]
|
||||
#[proc_macro]
|
||||
pub fn render(tokens: TokenStream) -> TokenStream {
|
||||
rsx(tokens)
|
||||
}
|
||||
|
||||
#[doc = include_str!("../docs/component.md")]
|
||||
#[proc_macro_attribute]
|
||||
pub fn component(_args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
|
@ -61,39 +39,3 @@ pub fn component(_args: TokenStream, input: TokenStream) -> TokenStream {
|
|||
.into_token_stream()
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Derive props for a component within the component definition.
|
||||
///
|
||||
/// This macro provides a simple transformation from `Scope<{}>` to `Scope<P>`,
|
||||
/// removing some boilerplate when defining props.
|
||||
///
|
||||
/// You don't *need* to use this macro at all, but it can be helpful in cases where
|
||||
/// you would be repeating a lot of the usual Rust boilerplate.
|
||||
///
|
||||
/// # Example
|
||||
/// ```rust,no_run
|
||||
/// # use dioxus::prelude::*;
|
||||
/// #[inline_props]
|
||||
/// fn GreetBob(bob: String) -> Element {
|
||||
/// rsx! { "hello, {bob}" }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// is equivalent to
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// # use dioxus::prelude::*;
|
||||
/// #[derive(PartialEq, Props, Clone)]
|
||||
/// struct AppProps {
|
||||
/// bob: String,
|
||||
/// }
|
||||
///
|
||||
/// fn GreetBob(props: AppProps) -> Element {
|
||||
/// rsx! { "hello, {props.bob}" }
|
||||
/// }
|
||||
/// ```
|
||||
#[proc_macro_attribute]
|
||||
#[deprecated(note = "Use `#[component]` instead.")]
|
||||
pub fn inline_props(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
component(args, input)
|
||||
}
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
use dioxus_core_macro::*;
|
||||
|
||||
#[test]
|
||||
fn formatting_compiles() {
|
||||
let x = (0, 1);
|
||||
// escape sequences work
|
||||
assert_eq!(
|
||||
format_args_f!("{x:?} {{}}}}").to_string(),
|
||||
format!("{x:?} {{}}}}")
|
||||
);
|
||||
assert_eq!(
|
||||
format_args_f!("{{{{}} {x:?}").to_string(),
|
||||
format!("{{{{}} {x:?}")
|
||||
);
|
||||
|
||||
// paths in formating works
|
||||
assert_eq!(format_args_f!("{x.0}").to_string(), format!("{}", x.0));
|
||||
|
||||
// function calls in formatings work
|
||||
assert_eq!(
|
||||
format_args_f!("{blah(&x):?}").to_string(),
|
||||
format!("{:?}", blah(&x))
|
||||
);
|
||||
|
||||
// allows duplicate format args
|
||||
assert_eq!(
|
||||
format_args_f!("{x:?} {x:?}").to_string(),
|
||||
format!("{x:?} {x:?}")
|
||||
);
|
||||
}
|
||||
|
||||
fn blah(hi: &(i32, i32)) -> String {
|
||||
format_args_f!("{hi.0} {hi.1}").to_string()
|
||||
}
|
|
@ -33,7 +33,7 @@ pub mod prelude {
|
|||
|
||||
#[cfg(feature = "macro")]
|
||||
#[allow(deprecated)]
|
||||
pub use dioxus_core_macro::{component, format_args_f, inline_props, render, rsx, Props};
|
||||
pub use dioxus_core_macro::{component, rsx, Props};
|
||||
|
||||
#[cfg(feature = "macro")]
|
||||
pub use dioxus_config_macro::*;
|
||||
|
|
|
@ -77,7 +77,7 @@ pub mod prelude {
|
|||
#[cfg(feature = "macro")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "macro")))]
|
||||
#[allow(deprecated)]
|
||||
pub use dioxus_core_macro::{component, format_args_f, inline_props, render, rsx, Props};
|
||||
pub use dioxus_core_macro::{component, rsx, Props};
|
||||
|
||||
#[cfg(feature = "launch")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "launch")))]
|
||||
|
|
Loading…
Add table
Reference in a new issue