rename TupleBuilder to NextTuple and prep for release

This commit is contained in:
Greg Johnston 2024-04-27 11:22:04 -04:00
parent 11d134c4ba
commit e68730d15f
9 changed files with 43 additions and 38 deletions

View File

@ -59,6 +59,7 @@ leptos_reactive = { path = "./leptos_reactive", version = "0.7.0-preview" }
leptos_router = { path = "./router", version = "0.7.0-preview" }
leptos_server = { path = "./leptos_server", version = "0.7.0-preview" }
leptos_meta = { path = "./meta", version = "0.7.0-preview" }
next_tuple = { path = "./next_tuple", version = "0.1" }
oco_ref = { path = "./oco", version = "0.2" }
or_poisoned = { path = "./or_poisoned", version = "0.1" }
reactive_graph = { path = "./reactive_graph", version = "0.1.0-preview" }

View File

@ -15,7 +15,7 @@ use leptos::{
view::{Mountable, Render},
},
};
use next_tuple::TupleBuilder;
use next_tuple::NextTuple;
use std::{borrow::Cow, marker::PhantomData};
#[derive(Debug)]
@ -219,7 +219,7 @@ pub struct LGtkWidget<Widg, Props, Chil> {
impl<Widg, Props, Chil> LGtkWidget<Widg, Props, Chil>
where
Widg: WidgetClass,
Chil: TupleBuilder,
Chil: NextTuple,
{
pub fn child<T>(
self,
@ -240,7 +240,7 @@ where
impl<Widg, Props, Chil> LGtkWidget<Widg, Props, Chil>
where
Widg: WidgetClass,
Props: TupleBuilder,
Props: NextTuple,
Chil: Render<LeptosGtk>,
{
pub fn connect<F>(
@ -417,7 +417,7 @@ pub mod properties {
};
use gtk::glib::{object::ObjectExt, Value};
use leptos::tachys::{renderer::Renderer, view::Render};
use next_tuple::TupleBuilder;
use next_tuple::NextTuple;
pub struct Connect<F>
where
@ -468,7 +468,7 @@ pub mod properties {
impl<Widg, Props, Chil> LGtkWidget<Widg, Props, Chil>
where
Widg: WidgetClass,
Props: TupleBuilder,
Props: NextTuple,
Chil: Render<LeptosGtk>,
{
pub fn orientation(
@ -517,7 +517,7 @@ pub mod properties {
impl<Widg, Props, Chil> LGtkWidget<Widg, Props, Chil>
where
Widg: WidgetClass,
Props: TupleBuilder,
Props: NextTuple,
Chil: Render<LeptosGtk>,
{
pub fn spacing(

View File

@ -1,6 +1,12 @@
[package]
name = "next_tuple"
version = "0.1.0"
version = "0.1.0-preview"
edition = "2021"
authors = ["Greg Johnston"]
license = "MIT"
readme = "../README.md"
repository = "https://github.com/leptos-rs/leptos"
description = "A trait to build and extend tuples."
rust-version.workspace = true
[dependencies]

1
next_tuple/README.md Normal file
View File

@ -0,0 +1 @@
Allows extending a tuple, or creating a new tuple, by adding the next value.

View File

@ -1,21 +1,19 @@
#![no_std]
#![allow(non_snake_case)]
#![forbid(unsafe_code)]
pub trait TupleBuilder {
/// Allows extending a tuple, or creating a new tuple, by adding the next value.
pub trait NextTuple {
/// The type that will be returned by adding another value of type `Next` to the end of the current type.
type Output<Next>;
/// Adds the next value and returns the result.
fn next_tuple<Next>(self, next: Next) -> Self::Output<Next>;
}
pub trait ConcatTuples<Next> {
type Output;
fn concat(self, next: Next) -> Self::Output;
}
macro_rules! impl_tuple_builder {
($($ty:ident),*) => {
impl<$($ty),*> TupleBuilder for ($($ty,)*) {
impl<$($ty),*> NextTuple for ($($ty,)*) {
type Output<Next> = ($($ty,)* Next);
fn next_tuple<Next>(self, next: Next) -> Self::Output<Next> {
@ -26,7 +24,7 @@ macro_rules! impl_tuple_builder {
};
}
impl TupleBuilder for () {
impl NextTuple for () {
type Output<Next> = (Next,);
fn next_tuple<Next>(self, next: Next) -> Self::Output<Next> {

View File

@ -10,7 +10,7 @@ use crate::{
renderer::{dom::Dom, Renderer},
view::Render,
};
use next_tuple::TupleBuilder;
use next_tuple::NextTuple;
use once_cell::unsync::Lazy;
use std::{fmt::Debug, marker::PhantomData};
@ -51,13 +51,13 @@ macro_rules! html_elements {
#[doc = concat!("The [`", stringify!($attr), "`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/", stringify!($tag), "#", stringify!($attr) ,") attribute on `<", stringify!($tag), ">`.")]
pub fn $attr<V>(self, value: V) -> HtmlElement <
[<$tag:camel>],
<At as TupleBuilder>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>,
<At as NextTuple>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>,
Ch, Rndr
>
where
V: AttributeValue<Rndr>,
At: TupleBuilder,
<At as TupleBuilder>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>: Attribute<Rndr>,
At: NextTuple,
<At as NextTuple>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>: Attribute<Rndr>,
{
let HtmlElement { tag, rndr, children, attributes } = self;
HtmlElement {
@ -144,14 +144,14 @@ macro_rules! html_self_closing_elements {
#[doc = concat!("The [`", stringify!($attr), "`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/", stringify!($tag), "#", stringify!($attr) ,") attribute on `<", stringify!($tag), ">`.")]
pub fn $attr<V>(self, value: V) -> HtmlElement<
[<$tag:camel>],
<At as TupleBuilder>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>,
<At as NextTuple>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>,
(),
Rndr
>
where
V: AttributeValue<Rndr>,
At: TupleBuilder,
<At as TupleBuilder>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>: Attribute<Rndr>,
At: NextTuple,
<At as NextTuple>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>: Attribute<Rndr>,
{
let HtmlElement { tag, rndr, children, attributes } = self;

View File

@ -11,7 +11,7 @@ use crate::{
use const_str_slice_concat::{
const_concat, const_concat_with_prefix, str_from_buffer,
};
use next_tuple::TupleBuilder;
use next_tuple::NextTuple;
use std::{
future::Future,
marker::PhantomData,
@ -72,13 +72,12 @@ impl<E, At, Ch, NewChild, Rndr> ElementChild<Rndr, NewChild>
for HtmlElement<E, At, Ch, Rndr>
where
E: ElementWithChildren,
Ch: Render<Rndr> + TupleBuilder,
<Ch as TupleBuilder>::Output<NewChild>: Render<Rndr>,
Ch: Render<Rndr> + NextTuple,
<Ch as NextTuple>::Output<NewChild>: Render<Rndr>,
Rndr: Renderer,
NewChild: Render<Rndr>,
{
type Output =
HtmlElement<E, At, <Ch as TupleBuilder>::Output<NewChild>, Rndr>;
type Output = HtmlElement<E, At, <Ch as NextTuple>::Output<NewChild>, Rndr>;
fn child(self, child: NewChild) -> Self::Output {
let HtmlElement {

View File

@ -8,7 +8,7 @@ use crate::{
renderer::{dom::Dom, Renderer},
view::Render,
};
use next_tuple::TupleBuilder;
use next_tuple::NextTuple;
use once_cell::unsync::Lazy;
use std::{fmt::Debug, marker::PhantomData};
@ -17,13 +17,13 @@ macro_rules! mathml_global {
paste::paste! {
pub fn $attr<V>(self, value: V) -> HtmlElement <
[<$tag:camel>],
<At as TupleBuilder>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>,
<At as NextTuple>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>,
Ch, Rndr
>
where
V: AttributeValue<Rndr>,
At: TupleBuilder,
<At as TupleBuilder>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>: Attribute<Rndr>,
At: NextTuple,
<At as NextTuple>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>: Attribute<Rndr>,
{
let HtmlElement { tag, rndr, children, attributes } = self;
HtmlElement {
@ -75,13 +75,13 @@ macro_rules! mathml_elements {
$(
pub fn $attr<V>(self, value: V) -> HtmlElement <
[<$tag:camel>],
<At as TupleBuilder>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>,
<At as NextTuple>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>,
Ch, Rndr
>
where
V: AttributeValue<Rndr>,
At: TupleBuilder,
<At as TupleBuilder>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>: Attribute<Rndr>,
At: NextTuple,
<At as NextTuple>::Output<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>: Attribute<Rndr>,
{
let HtmlElement { tag, rndr, children, attributes } = self;
HtmlElement {

View File

@ -41,13 +41,13 @@ macro_rules! svg_elements {
$(
pub fn $attr<V>(self, value: V) -> HtmlElement <
[<$tag:camel>],
<At as TupleBuilder<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>>::Output,
<At as NextTuple<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>>::Output,
Ch, Rndr
>
where
V: AttributeValue<Rndr>,
At: TupleBuilder<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>,
<At as TupleBuilder<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>>::Output: Attribute<Rndr>,
At: NextTuple<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>,
<At as NextTuple<Attr<$crate::html::attribute::[<$attr:camel>], V, Rndr>>>::Output: Attribute<Rndr>,
{
let HtmlElement { tag, rndr, children, attributes } = self;
HtmlElement {