Skip to content

Commit 9971ff2

Browse files
committed
polish: change in cx to cx
1 parent 0ded32e commit 9971ff2

File tree

21 files changed

+408
-302
lines changed

21 files changed

+408
-302
lines changed

docs/main-concepts/03-rsx.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ pub static Example: FC<()> = |cx| {
113113
// rsx! is lazy, and the underlying closures cannot have the same type
114114
// Rendering produces the VNode type
115115
{match rand::gen_range::<i32>(1..3) {
116-
1 => rsx!(in cx, h1 { "big" })
117-
2 => rsx!(in cx, h2 { "medium" })
118-
_ => rsx!(in cx, h3 { "small" })
116+
1 => rsx!(cx, h1 { "big" })
117+
2 => rsx!(cx, h2 { "medium" })
118+
_ => rsx!(cx, h3 { "small" })
119119
}}
120120

121121
// Optionals
@@ -128,7 +128,7 @@ pub static Example: FC<()> = |cx| {
128128
// Duplicating nodes
129129
// Clones the nodes by reference, so they are literally identical
130130
{{
131-
let node = rsx!(in cx, h1{ "TopNode" });
131+
let node = rsx!(cx, h1{ "TopNode" });
132132
(0..10).map(|_| node.clone())
133133
}}
134134

docs/main-concepts/12-signals.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Sometimes you want a signal to propagate across your app, either through far-awa
9898
const TITLE: Atom<String> = || "".to_string();
9999
const Provider: FC<()> = |cx| {
100100
let title = use_signal(&cx, &TITLE);
101-
rsx!(in cx, input { value: title })
101+
rsx!(cx, input { value: title })
102102
};
103103
```
104104

@@ -108,7 +108,7 @@ If we use the `TITLE` atom in another component, we can cause updates to flow be
108108
const Receiver: FC<()> = |cx| {
109109
let title = use_signal(&cx, &TITLE);
110110
log::info!("This will only be called once!");
111-
rsx!(in cx,
111+
rsx!(cx,
112112
div {
113113
h1 { "{title}" }
114114
div {}

examples/reference/antipatterns.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ struct NoKeysProps {
3434
}
3535
static AntipatternNoKeys: FC<NoKeysProps> = |cx| {
3636
// WRONG: Make sure to add keys!
37-
rsx!(in cx, ul {
37+
rsx!(cx, ul {
3838
{cx.data.iter().map(|(k, v)| rsx!(li { "List item: {v}" }))}
3939
});
4040
// RIGHT: Like this:
41-
rsx!(in cx, ul {
41+
rsx!(cx, ul {
4242
{cx.data.iter().map(|(k, v)| rsx!(li { key: "{k}", "List item: {v}" }))}
4343
})
4444
};
@@ -56,7 +56,7 @@ static AntipatternNoKeys: FC<NoKeysProps> = |cx| {
5656
/// an API for registering shared state without the ContextProvider pattern.
5757
static AntipatternNestedFragments: FC<()> = |cx| {
5858
// Try to avoid heavily nesting fragments
59-
rsx!(in cx,
59+
rsx!(cx,
6060
Fragment {
6161
Fragment {
6262
Fragment {
@@ -125,9 +125,9 @@ static AntipatternMisusedHooks: FC<MisuedHooksProps> = |cx| {
125125
// do not place a hook in the conditional!
126126
// prefer to move it out of the conditional
127127
let (state, set_state) = use_state(cx, || "hello world").classic();
128-
rsx!(in cx, div { "{state}" })
128+
rsx!(cx, div { "{state}" })
129129
} else {
130-
rsx!(in cx, div { "Not rendering state" })
130+
rsx!(cx, div { "Not rendering state" })
131131
}
132132
};
133133

examples/reference/conditional_rendering.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub static Example0: FC<MyProps> = |cx| {
3434
// which will do essentially the same thing as `cx.render`.
3535
//
3636
// In short:
37-
// `rsx!(in cx, ...)` is shorthand for `cx.render(rsx!(...))`
37+
// `rsx!(cx, ...)` is shorthand for `cx.render(rsx!(...))`
3838
#[derive(PartialEq, Props)]
3939
pub struct MyProps1 {
4040
should_show: bool,
@@ -45,21 +45,21 @@ pub static Example1: FC<MyProps1> = |cx| {
4545
// With matching
4646
{match cx.should_show {
4747
true => cx.render(rsx!(div {"it is true!"})),
48-
false => rsx!(in cx, div {"it is false!"}),
48+
false => rsx!(cx, div {"it is false!"}),
4949
}}
5050

5151
// or with just regular conditions
5252
{if cx.should_show {
53-
rsx!(in cx, div {"it is true!"})
53+
rsx!(cx, div {"it is true!"})
5454
} else {
55-
rsx!(in cx, div {"it is false!"})
55+
rsx!(cx, div {"it is false!"})
5656
}}
5757

5858
// or with optional chaining
5959
{
6060
cx.should_show
61-
.then(|| rsx!(in cx, div {"it is false!"}))
62-
.unwrap_or_else(|| rsx!(in cx, div {"it is false!"}))
61+
.then(|| rsx!(cx, div {"it is false!"}))
62+
.unwrap_or_else(|| rsx!(cx, div {"it is false!"}))
6363
}
6464
}
6565
})
@@ -81,9 +81,9 @@ pub static Example2: FC<MyProps2> = |cx| {
8181
cx.render(rsx! {
8282
div {
8383
{match cx.color {
84-
Color::Green => rsx!(in cx, div {"it is Green!"}),
85-
Color::Yellow => rsx!(in cx, div {"it is Yellow!"}),
86-
Color::Red => rsx!(in cx, div {"it is Red!"}),
84+
Color::Green => rsx!(cx, div {"it is Green!"}),
85+
Color::Yellow => rsx!(cx, div {"it is Yellow!"}),
86+
Color::Red => rsx!(cx, div {"it is Red!"}),
8787
}}
8888
}
8989
})

examples/reference/listener.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static ButtonList: FC<()> = |cx| {
3434
/// This shows how listeners may be without a visible change in the display.
3535
/// Check the console.
3636
static NonUpdatingEvents: FC<()> = |cx| {
37-
rsx!(in cx, div {
37+
rsx!(cx, div {
3838
button {
3939
onclick: move |_| log::info!("Did not cause any updates!")
4040
"Click me to log!"
@@ -43,7 +43,7 @@ static NonUpdatingEvents: FC<()> = |cx| {
4343
};
4444

4545
static DisablePropogation: FC<()> = |cx| {
46-
rsx!(in cx,
46+
rsx!(cx,
4747
div {
4848
onclick: move |_| log::info!("event propogated to the div!")
4949
button {

examples/reference/suspense.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ pub static Example: FC<()> = |cx| {
1919
cx,
2020
|| surf::get(ENDPOINT).recv_json::<DogApi>(),
2121
|cx, res| match res {
22-
Ok(res) => rsx!(in cx, img { src: "{res.message}" }),
23-
Err(_) => rsx!(in cx, div { "No doggos for you :(" }),
22+
Ok(res) => rsx!(cx, img { src: "{res.message}" }),
23+
Err(_) => rsx!(cx, div { "No doggos for you :(" }),
2424
},
2525
);
2626

examples/rsx_usage.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub static Example: FC<()> = |cx| {
106106
// To fix this, call "render" method or use the "in" syntax to produce VNodes.
107107
// There's nothing we can do about it, sorry :/ (unless you want *really* unhygenic macros)
108108
{match true {
109-
true => rsx!(in cx, h1 {"Top text"}),
109+
true => rsx!(cx, h1 {"Top text"}),
110110
false => cx.render(rsx!( h1 {"Bottom text"}))
111111
}}
112112

@@ -117,9 +117,9 @@ pub static Example: FC<()> = |cx| {
117117

118118
// True conditions need to be rendered (same reasons as matching)
119119
{if true {
120-
rsx!(in cx, h1 {"Top text"})
120+
rsx!(cx, h1 {"Top text"})
121121
} else {
122-
rsx!(in cx, h1 {"Bottom text"})
122+
rsx!(cx, h1 {"Bottom text"})
123123
}}
124124

125125
// returning "None" is a bit noisy... but rare in practice

examples/showcase.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ static App: FC<()> = |cx| {
1515
let (selection, set_selection) = use_state(cx, || None as Option<usize>).classic();
1616

1717
let body = match selection {
18-
Some(id) => rsx!(in cx, ReferenceItem { selected: *id }),
19-
None => rsx!(in cx, div { "Select an concept to explore" }),
18+
Some(id) => rsx!(cx, ReferenceItem { selected: *id }),
19+
None => rsx!(cx, div { "Select an concept to explore" }),
2020
};
2121

2222
cx.render(rsx! {

packages/core-macro/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub fn derive_typed_builder(input: proc_macro::TokenStream) -> proc_macro::Token
8787
/// // To fix this, call "render" method or use the "in" syntax to produce VNodes.
8888
/// // There's nothing we can do about it, sorry :/ (unless you want *really* unhygenic macros)
8989
/// {match true {
90-
/// true => rsx!(in cx, h1 {"Top text"}),
90+
/// true => rsx!(cx, h1 {"Top text"}),
9191
/// false => cx.render(rsx!( h1 {"Bottom text"}))
9292
/// }}
9393
///
@@ -98,9 +98,9 @@ pub fn derive_typed_builder(input: proc_macro::TokenStream) -> proc_macro::Token
9898
///
9999
/// // True conditions need to be rendered (same reasons as matching)
100100
/// {if true {
101-
/// rsx!(in cx, h1 {"Top text"})
101+
/// rsx!(cx, h1 {"Top text"})
102102
/// } else {
103-
/// rsx!(in cx, h1 {"Bottom text"})
103+
/// rsx!(cx, h1 {"Bottom text"})
104104
/// }}
105105
///
106106
/// // returning "None" is a bit noisy... but rare in practice

packages/core-macro/src/rsx/body.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ impl Parse for RsxBody<AS_HTML> {
3939
}
4040

4141
fn try_parse_custom_context(input: ParseStream) -> Result<Option<Ident>> {
42-
let res = if input.peek(Token![in]) && input.peek2(Ident) && input.peek3(Token![,]) {
43-
let _ = input.parse::<Token![in]>()?;
42+
let res = if input.peek(Ident) && input.peek2(Token![,]) {
4443
let name = input.parse::<Ident>()?;
4544
input.parse::<Token![,]>()?;
4645
Some(name)

0 commit comments

Comments
 (0)