Add space between rsx and exclamation point (#2956)

This commit is contained in:
Jonathan Kelley authored and GitHub committed 2024-09-13 08:31:39 -05:00
1 parent 8d68886310
commit c7124e41fb
20 files changed
+41 -41

No files matched your search

+1 -1
View File
@@ -81,7 +81,7 @@ fn ParseNumberWithShow() -> Element {
let request_data = "0.5"; let request_data = "0.5";
let data: i32 = request_data.parse() let data: i32 = request_data.parse()
// You can attach rsx to results that can be displayed in the Error Boundary // You can attach rsx to results that can be displayed in the Error Boundary
.show(|_| rsx!{ .show(|_| rsx! {
div { div {
background_color: "red", background_color: "red",
border: "black", border: "black",
+3 -3
View File
@@ -106,7 +106,7 @@ pub trait Context<T, E>: private::Sealed {
/// "Error parsing number: {error}" /// "Error parsing number: {error}"
/// } /// }
/// })?; /// })?;
/// todo!() /// unimplemented!()
/// } /// }
/// ``` /// ```
fn show(self, display_error: impl FnOnce(&E) -> Element) -> Result<T>; fn show(self, display_error: impl FnOnce(&E) -> Element) -> Result<T>;
@@ -120,7 +120,7 @@ pub trait Context<T, E>: private::Sealed {
/// // You can bubble up errors with `?` inside components, and event handlers /// // You can bubble up errors with `?` inside components, and event handlers
/// // Along with the error itself, you can provide a way to display the error by calling `context` /// // Along with the error itself, you can provide a way to display the error by calling `context`
/// let number = "-1234".parse::<usize>().context("Parsing number inside of the NumberParser")?; /// let number = "-1234".parse::<usize>().context("Parsing number inside of the NumberParser")?;
/// todo!() /// unimplemented!()
/// } /// }
/// ``` /// ```
fn context<C: Display + 'static>(self, context: C) -> Result<T>; fn context<C: Display + 'static>(self, context: C) -> Result<T>;
@@ -134,7 +134,7 @@ pub trait Context<T, E>: private::Sealed {
/// // You can bubble up errors with `?` inside components, and event handlers /// // You can bubble up errors with `?` inside components, and event handlers
/// // Along with the error itself, you can provide a way to display the error by calling `context` /// // Along with the error itself, you can provide a way to display the error by calling `context`
/// let number = "-1234".parse::<usize>().with_context(|| format!("Timestamp: {:?}", std::time::Instant::now()))?; /// let number = "-1234".parse::<usize>().with_context(|| format!("Timestamp: {:?}", std::time::Instant::now()))?;
/// todo!() /// unimplemented!()
/// } /// }
/// ``` /// ```
fn with_context<C: Display + 'static>(self, context: impl FnOnce() -> C) -> Result<T>; fn with_context<C: Display + 'static>(self, context: impl FnOnce() -> C) -> Result<T>;
+5 -5
View File
@@ -201,7 +201,7 @@ impl<T: std::fmt::Debug> std::fmt::Debug for Event<T> {
/// ///
/// ```rust, no_run /// ```rust, no_run
/// # use dioxus::prelude::*; /// # use dioxus::prelude::*;
/// rsx!{ /// rsx! {
/// MyComponent { onclick: move |evt| tracing::debug!("clicked") } /// MyComponent { onclick: move |evt| tracing::debug!("clicked") }
/// }; /// };
/// ///
@@ -211,7 +211,7 @@ impl<T: std::fmt::Debug> std::fmt::Debug for Event<T> {
/// } /// }
/// ///
/// fn MyComponent(cx: MyProps) -> Element { /// fn MyComponent(cx: MyProps) -> Element {
/// rsx!{ /// rsx! {
/// button { /// button {
/// onclick: move |evt| cx.onclick.call(evt), /// onclick: move |evt| cx.onclick.call(evt),
/// } /// }
@@ -228,7 +228,7 @@ pub type EventHandler<T = ()> = Callback<T>;
/// # Example /// # Example
/// ///
/// ```rust, ignore /// ```rust, ignore
/// rsx!{ /// rsx! {
/// MyComponent { onclick: move |evt| { /// MyComponent { onclick: move |evt| {
/// tracing::debug!("clicked"); /// tracing::debug!("clicked");
/// 42 /// 42
@@ -241,7 +241,7 @@ pub type EventHandler<T = ()> = Callback<T>;
/// } /// }
/// ///
/// fn MyComponent(cx: MyProps) -> Element { /// fn MyComponent(cx: MyProps) -> Element {
/// rsx!{ /// rsx! {
/// button { /// button {
/// onclick: move |evt| println!("number: {}", cx.onclick.call(evt)), /// onclick: move |evt| println!("number: {}", cx.onclick.call(evt)),
/// } /// }
@@ -256,7 +256,7 @@ pub struct Callback<Args = (), Ret = ()> {
/// # use dioxus::prelude::*; /// # use dioxus::prelude::*;
/// #[component] /// #[component]
/// fn Child(onclick: EventHandler<MouseEvent>) -> Element { /// fn Child(onclick: EventHandler<MouseEvent>) -> Element {
/// rsx!{ /// rsx! {
/// button { /// button {
/// // Diffing Child will not rerun this component, it will just update the callback in place so that if this callback is called, it will run the latest version of the callback /// // Diffing Child will not rerun this component, it will just update the callback in place so that if this callback is called, it will run the latest version of the callback
/// onclick: move |evt| onclick(evt), /// onclick: move |evt| onclick(evt),
+2 -2
View File
@@ -14,7 +14,7 @@ use crate::innerlude::*;
/// ```rust /// ```rust
/// # use dioxus::prelude::*; /// # use dioxus::prelude::*;
/// let value = 1; /// let value = 1;
/// rsx!{ /// rsx! {
/// Fragment { key: "{value}" } /// Fragment { key: "{value}" }
/// }; /// };
/// ``` /// ```
@@ -76,7 +76,7 @@ impl<const A: bool> FragmentBuilder<A> {
/// ///
/// #[component] /// #[component]
/// fn CustomCard(children: Element) -> Element { /// fn CustomCard(children: Element) -> Element {
/// rsx!{ /// rsx! {
/// div { /// div {
/// h1 {"Title card"} /// h1 {"Title card"}
/// {children} /// {children}
+3 -3
View File
@@ -25,13 +25,13 @@ pub fn vdom_is_rendering() -> bool {
/// fn Component() -> Element { /// fn Component() -> Element {
/// let request = spawn(async move { /// let request = spawn(async move {
/// match reqwest::get("https://api.example.com").await { /// match reqwest::get("https://api.example.com").await {
/// Ok(_) => todo!(), /// Ok(_) => unimplemented!(),
/// // You can explicitly throw an error into a scope with throw_error /// // You can explicitly throw an error into a scope with throw_error
/// Err(err) => ScopeId::APP.throw_error(err) /// Err(err) => ScopeId::APP.throw_error(err)
/// } /// }
/// }); /// });
/// ///
/// todo!() /// unimplemented!()
/// } /// }
/// ``` /// ```
pub fn throw_error(error: impl Into<CapturedError> + 'static) { pub fn throw_error(error: impl Into<CapturedError> + 'static) {
@@ -351,7 +351,7 @@ pub fn schedule_update_any() -> Arc<dyn Fn(ScopeId) + Send + Sync> {
/// window.scroll_with_x_and_y(original_scroll_position(), 0.0); /// window.scroll_with_x_and_y(original_scroll_position(), 0.0);
/// }); /// });
/// ///
/// rsx!{ /// rsx! {
/// div { /// div {
/// id: "my_element", /// id: "my_element",
/// "hello" /// "hello"
+1 -1
View File
@@ -435,7 +435,7 @@ impl Runtime {
/// } /// }
/// ///
/// fn app() -> Element { /// fn app() -> Element {
/// rsx!{ Component { runtime: Runtime::current().unwrap() } } /// rsx! { Component { runtime: Runtime::current().unwrap() } }
/// } /// }
/// ///
/// // In a dynamic library /// // In a dynamic library
+2 -2
View File
@@ -558,13 +558,13 @@ impl ScopeId {
/// fn Component() -> Element { /// fn Component() -> Element {
/// let request = spawn(async move { /// let request = spawn(async move {
/// match reqwest::get("https://api.example.com").await { /// match reqwest::get("https://api.example.com").await {
/// Ok(_) => todo!(), /// Ok(_) => unimplemented!(),
/// // You can explicitly throw an error into a scope with throw_error /// // You can explicitly throw an error into a scope with throw_error
/// Err(err) => ScopeId::APP.throw_error(err) /// Err(err) => ScopeId::APP.throw_error(err)
/// } /// }
/// }); /// });
/// ///
/// todo!() /// unimplemented!()
/// } /// }
/// ``` /// ```
pub fn throw_error(self, error: impl Into<CapturedError> + 'static) { pub fn throw_error(self, error: impl Into<CapturedError> + 'static) {
+2 -2
View File
@@ -269,7 +269,7 @@ impl VirtualDom {
/// } /// }
/// ///
/// fn Example(cx: SomeProps) -> Element { /// fn Example(cx: SomeProps) -> Element {
/// rsx!{ div { "hello {cx.name}" } } /// rsx! { div { "hello {cx.name}" } }
/// } /// }
/// ///
/// let dom = VirtualDom::new_with_props(Example, SomeProps { name: "world" }); /// let dom = VirtualDom::new_with_props(Example, SomeProps { name: "world" });
@@ -285,7 +285,7 @@ impl VirtualDom {
/// # name: &'static str /// # name: &'static str
/// # } /// # }
/// # fn Example(cx: SomeProps) -> Element { /// # fn Example(cx: SomeProps) -> Element {
/// # rsx!{ div { "hello {cx.name}" } } /// # rsx! { div { "hello {cx.name}" } }
/// # } /// # }
/// let mut dom = VirtualDom::new_with_props(Example, SomeProps { name: "jane" }); /// let mut dom = VirtualDom::new_with_props(Example, SomeProps { name: "jane" });
/// dom.rebuild_in_place(); /// dom.rebuild_in_place();
@@ -17,7 +17,7 @@ use serde::{de::DeserializeOwned, Serialize};
/// 1234 /// 1234
/// }); /// });
/// ///
/// todo!() /// unimplemented!()
/// } /// }
/// ``` /// ```
pub fn use_server_cached<O: 'static + Clone + Serialize + DeserializeOwned>( pub fn use_server_cached<O: 'static + Clone + Serialize + DeserializeOwned>(
@@ -40,7 +40,7 @@ use std::future::Future;
/// ///
/// ```rust, no_run /// ```rust, no_run
/// # use dioxus::prelude::*; /// # use dioxus::prelude::*;
/// # async fn fetch_article(id: u32) -> String { todo!() } /// # async fn fetch_article(id: u32) -> String { unimplemented!() }
/// use dioxus::prelude::*; /// use dioxus::prelude::*;
/// ///
/// fn App() -> Element { /// fn App() -> Element {
+1 -1
View File
@@ -40,7 +40,7 @@ static TodoList: Component = |cx| {
let todos = use_map(|| HashMap::new()); let todos = use_map(|| HashMap::new());
let input = use_signal(|| None); let input = use_signal(|| None);
rsx!{ rsx! {
div { div {
button { button {
"Add todo" "Add todo"
+1 -1
View File
@@ -61,7 +61,7 @@ use std::future::Future;
/// }); /// });
/// ///
/// ///
/// rsx!{ /// rsx! {
/// button { /// button {
/// onclick: move |_| chat_client.send(Action::Start), /// onclick: move |_| chat_client.send(Action::Start),
/// "Start Chat Service" /// "Start Chat Service"
+1 -1
View File
@@ -92,7 +92,7 @@ fn Route1(user_id: usize, dynamic: usize, query: String) -> Element {
fn Route2(user_id: usize) -> Element { fn Route2(user_id: usize) -> Element {
rsx! { rsx! {
pre { "Route2{{\n\tuser_id:{user_id}\n}}" } pre { "Route2{{\n\tuser_id:{user_id}\n}}" }
{(0..user_id).map(|i| rsx!{ p { "{i}" } })} {(0..user_id).map(|i| rsx! { p { "{i}" } })}
p { "Footer" } p { "Footer" }
Link { Link {
to: Route::Route3 { to: Route::Route3 {
+3 -3
View File
@@ -3,17 +3,17 @@ use std::str::FromStr;
#[component] #[component]
fn Root() -> Element { fn Root() -> Element {
todo!() unimplemented!()
} }
#[component] #[component]
fn Test() -> Element { fn Test() -> Element {
todo!() unimplemented!()
} }
#[component] #[component]
fn Dynamic(id: usize) -> Element { fn Dynamic(id: usize) -> Element {
todo!() unimplemented!()
} }
// Make sure trailing '/'s work correctly // Make sure trailing '/'s work correctly
+1 -1
View File
@@ -1,7 +1,7 @@
#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/79236386")] #![doc(html_logo_url = "https://avatars.githubusercontent.com/u/79236386")]
#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/79236386")] #![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/79236386")]
//! Parse the root tokens in the rsx!{ } macro //! Parse the root tokens in the rsx! { } macro
//! ========================================= //! =========================================
//! //!
//! This parsing path emerges directly from the macro call, with `RsxRender` being the primary entrance into parsing. //! This parsing path emerges directly from the macro call, with `RsxRender` being the primary entrance into parsing.
+9 -9
View File
@@ -501,7 +501,7 @@ fn template_generates() {
"width2": 100, "width2": 100,
"height2": "100px", "height2": "100px",
p { "hello world" } p { "hello world" }
{(0..10).map(|i| rsx!{"{i}"})} {(0..10).map(|i| rsx! {"{i}"})}
} }
div { div {
width: 120, width: 120,
@@ -536,9 +536,9 @@ fn diffs_complex() {
"width2": 100, "width2": 100,
"height2": "100px", "height2": "100px",
p { "hello world" } p { "hello world" }
{(0..10).map(|i| rsx!{"{i}"})}, {(0..10).map(|i| rsx! {"{i}"})},
{(0..10).map(|i| rsx!{"{i}"})}, {(0..10).map(|i| rsx! {"{i}"})},
{(0..11).map(|i| rsx!{"{i}"})}, {(0..11).map(|i| rsx! {"{i}"})},
Comp {} Comp {}
} }
}; };
@@ -552,9 +552,9 @@ fn diffs_complex() {
"height2": "100px", "height2": "100px",
p { "hello world" } p { "hello world" }
Comp {} Comp {}
{(0..10).map(|i| rsx!{"{i}"})}, {(0..10).map(|i| rsx! {"{i}"})},
{(0..10).map(|i| rsx!{"{i}"})}, {(0..10).map(|i| rsx! {"{i}"})},
{(0..11).map(|i| rsx!{"{i}"})}, {(0..11).map(|i| rsx! {"{i}"})},
} }
}; };
@@ -570,12 +570,12 @@ fn remove_node() {
quote! { quote! {
svg { svg {
Comp {} Comp {}
{(0..10).map(|i| rsx!{"{i}"})}, {(0..10).map(|i| rsx! {"{i}"})},
} }
}, },
quote! { quote! {
div { div {
{(0..10).map(|i| rsx!{"{i}"})}, {(0..10).map(|i| rsx! {"{i}"})},
} }
}, },
) )
+1 -1
View File
@@ -98,7 +98,7 @@ fn complex_kitchen_sink() {
} }
})} })}
} }
div { class: "px-4", {is_current.then(|| rsx!{ children })} } div { class: "px-4", {is_current.then(|| rsx! { children })} }
} }
// No nesting // No nesting
+1 -1
View File
@@ -17,7 +17,7 @@ pub type WritableRef<'a, T: Writable, O = <T as Readable>::Target> = T::Mut<'a,
/// } /// }
/// ///
/// fn MyComponent(mut count: Signal<MyEnum>) -> Element { /// fn MyComponent(mut count: Signal<MyEnum>) -> Element {
/// rsx!{ /// rsx! {
/// button { /// button {
/// onclick: move |_| { /// onclick: move |_| {
/// // You can use any methods from the Writable trait on Signals /// // You can use any methods from the Writable trait on Signals
+1 -1
View File
@@ -12,7 +12,7 @@ fn app() -> Element {
"asd" "asd"
Bapp {} Bapp {}
} }
{(0..10).map(|f| rsx!{ {(0..10).map(|f| rsx! {
div { div {
"thing {f}" "thing {f}"
} }
+1 -1
View File
@@ -35,7 +35,7 @@ fn rehydrates() {
}, },
"listener test" "listener test"
} }
{false.then(|| rsx!{ "hello" })} {false.then(|| rsx! { "hello" })}
} }
} }
} }