Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
DanikVitek committed Jan 22, 2025
2 parents 7436a2f + ac33527 commit 4bcb823
Show file tree
Hide file tree
Showing 27 changed files with 680 additions and 84 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci-changed-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ on:
branches:
- main
- leptos_0.6
- leptos_0.8
pull_request:
branches:
- main
- leptos_0.6
- leptos_0.8
jobs:
get-example-changed:
uses: ./.github/workflows/get-example-changed.yml
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ on:
branches:
- main
- leptos_0.6
- leptos_0.8
pull_request:
branches:
- main
- leptos_0.6
- leptos_0.8
jobs:
get-leptos-changed:
uses: ./.github/workflows/get-leptos-changed.yml
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci-semver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ on:
branches:
- main
- leptos_0.6
- leptos_0.8
pull_request:
branches:
- main
- leptos_0.6
- leptos_0.8
env:
DEBIAN_FRONTEND: noninteractive
jobs:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ on:
branches:
- main
- leptos_0.6
- leptos_0.8
pull_request:
branches:
- main
- leptos_0.6
- leptos_0.8
jobs:
get-leptos-changed:
uses: ./.github/workflows/get-leptos-changed.yml
Expand Down
40 changes: 21 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ members = [
exclude = ["benchmarks", "examples", "projects"]

[workspace.package]
version = "0.7.3"
version = "0.7.4"
edition = "2021"
rust-version = "1.76"

Expand All @@ -50,25 +50,25 @@ any_spawner = { path = "./any_spawner/", version = "0.2.0" }
const_str_slice_concat = { path = "./const_str_slice_concat", version = "0.1.0" }
either_of = { path = "./either_of/", version = "0.1.0" }
hydration_context = { path = "./hydration_context", version = "0.2.0" }
leptos = { path = "./leptos", version = "0.7.3" }
leptos_config = { path = "./leptos_config", version = "0.7.3" }
leptos_dom = { path = "./leptos_dom", version = "0.7.3" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.7.3" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.7.3" }
leptos_macro = { path = "./leptos_macro", version = "0.7.3" }
leptos_router = { path = "./router", version = "0.7.3" }
leptos_router_macro = { path = "./router_macro", version = "0.7.3" }
leptos_server = { path = "./leptos_server", version = "0.7.3" }
leptos_meta = { path = "./meta", version = "0.7.3" }
leptos = { path = "./leptos", version = "0.7.4" }
leptos_config = { path = "./leptos_config", version = "0.7.4" }
leptos_dom = { path = "./leptos_dom", version = "0.7.4" }
leptos_hot_reload = { path = "./leptos_hot_reload", version = "0.7.4" }
leptos_integration_utils = { path = "./integrations/utils", version = "0.7.4" }
leptos_macro = { path = "./leptos_macro", version = "0.7.4" }
leptos_router = { path = "./router", version = "0.7.4" }
leptos_router_macro = { path = "./router_macro", version = "0.7.4" }
leptos_server = { path = "./leptos_server", version = "0.7.4" }
leptos_meta = { path = "./meta", version = "0.7.4" }
next_tuple = { path = "./next_tuple", version = "0.1.0" }
oco_ref = { path = "./oco", version = "0.2.0" }
or_poisoned = { path = "./or_poisoned", version = "0.1.0" }
reactive_graph = { path = "./reactive_graph", version = "0.1.0" }
reactive_stores = { path = "./reactive_stores", version = "0.1.0" }
reactive_stores_macro = { path = "./reactive_stores_macro", version = "0.1.0" }
server_fn = { path = "./server_fn", version = "0.7.3" }
server_fn_macro = { path = "./server_fn_macro", version = "0.7.3" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.7.3" }
server_fn = { path = "./server_fn", version = "0.7.4" }
server_fn_macro = { path = "./server_fn_macro", version = "0.7.4" }
server_fn_macro_default = { path = "./server_fn/server_fn_macro_default", version = "0.7.4" }
tachys = { path = "./tachys", version = "0.1.0" }

[profile.release]
Expand Down
80 changes: 80 additions & 0 deletions either_of/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,86 @@ where
}
}

pub trait EitherOr {
type Left;
type Right;
fn either_or<FA, A, FB, B>(self, a: FA, b: FB) -> Either<A, B>
where
FA: FnOnce(Self::Left) -> A,
FB: FnOnce(Self::Right) -> B;
}

impl EitherOr for bool {
type Left = ();
type Right = ();

fn either_or<FA, A, FB, B>(self, a: FA, b: FB) -> Either<A, B>
where
FA: FnOnce(Self::Left) -> A,
FB: FnOnce(Self::Right) -> B,
{
if self {
Either::Left(a(()))
} else {
Either::Right(b(()))
}
}
}

impl<T> EitherOr for Option<T> {
type Left = T;
type Right = ();

fn either_or<FA, A, FB, B>(self, a: FA, b: FB) -> Either<A, B>
where
FA: FnOnce(Self::Left) -> A,
FB: FnOnce(Self::Right) -> B,
{
match self {
Some(t) => Either::Left(a(t)),
None => Either::Right(b(())),
}
}
}

impl<T, E> EitherOr for Result<T, E> {
type Left = T;
type Right = E;

fn either_or<FA, A, FB, B>(self, a: FA, b: FB) -> Either<A, B>
where
FA: FnOnce(Self::Left) -> A,
FB: FnOnce(Self::Right) -> B,
{
match self {
Ok(t) => Either::Left(a(t)),
Err(err) => Either::Right(b(err)),
}
}
}

#[test]
fn test_either_or() {
let right = false.either_or(|_| 'a', |_| 12);
assert!(matches!(right, Either::Right(12)));

let left = true.either_or(|_| 'a', |_| 12);
assert!(matches!(left, Either::Left('a')));

let left = Some(12).either_or(|a| a, |_| 'a');
assert!(matches!(left, Either::Left(12)));
let right = None.either_or(|a: i32| a, |_| 'a');
assert!(matches!(right, Either::Right('a')));

let result: Result<_, ()> = Ok(1.2f32);
let left = result.either_or(|a| a * 2f32, |b| b);
assert!(matches!(left, Either::Left(2.4f32)));

let result: Result<i32, _> = Err("12");
let right = result.either_or(|a| a, |b| b.chars().next());
assert!(matches!(right, Either::Right(Some('1'))));
}

pin_project! {
#[project = EitherFutureProj]
pub enum EitherFuture<A, B> {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/axum_js_ssr/src/hljs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ mod csr {
extern "C" {
type HighlightOptions;

#[wasm_bindgen(catch, js_namespace = default, js_name = highlight)]
#[wasm_bindgen(catch, js_namespace = defaultMod, js_name = highlight)]
fn highlight_lang(
code: String,
options: Object,
) -> Result<Object, JsValue>;

#[wasm_bindgen(js_namespace = default, js_name = highlightAll)]
#[wasm_bindgen(js_namespace = defaultMod, js_name = highlightAll)]
pub fn highlight_all();
}

Expand Down
2 changes: 1 addition & 1 deletion leptos_macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "leptos_macro"
version = "0.7.3"
version = "0.7.4"
authors = ["Greg Johnston"]
license = "MIT"
repository = "https://github.com/leptos-rs/leptos"
Expand Down
Loading

0 comments on commit 4bcb823

Please sign in to comment.