♻️ Migra #[builder_fn] a #[builder_impl]

Sustituye las ~400 anotaciones `#[builder_fn]` método a método por un
único `#[builder_impl]` por `impl`/`trait`, en 74 ficheros de pagetop y
sus extensiones (admin, bootsier, menu, user).
This commit is contained in:
Manuel Cillero 2026-08-29 19:25:58 +02:00
parent c34dc02357
commit 1be3d88888
74 changed files with 104 additions and 394 deletions

View file

@ -1,4 +1,4 @@
use crate::{AutoDefault, builder_fn, util};
use crate::{AutoDefault, builder_impl, util};
// **< AttrName >***********************************************************************************
@ -24,6 +24,7 @@ use crate::{AutoDefault, builder_fn, util};
#[derive(AutoDefault, Clone, Debug)]
pub struct AttrName(Option<String>);
#[builder_impl]
impl AttrName {
/// Crea un nuevo `AttrName` normalizando el valor.
pub fn new(name: impl AsRef<str>) -> Self {
@ -33,7 +34,6 @@ impl AttrName {
// **< AttrName BUILDER >***********************************************************************
/// Establece un nombre nuevo normalizando el valor.
#[builder_fn]
pub fn with_name(mut self, name: impl AsRef<str>) -> Self {
self.0 = util::normalize_token(name);
self
@ -79,6 +79,7 @@ impl AttrName {
#[derive(AutoDefault, Clone, Debug)]
pub struct AttrValue(Option<String>);
#[builder_impl]
impl AttrValue {
/// Crea un nuevo `AttrValue` normalizando el valor.
pub fn new(value: impl AsRef<str>) -> Self {
@ -88,7 +89,6 @@ impl AttrValue {
// **< AttrValue BUILDER >**********************************************************************
/// Establece una cadena nueva normalizando el valor.
#[builder_fn]
pub fn with_str(mut self, value: impl AsRef<str>) -> Self {
self.0 = util::non_blank(value.as_ref()).map(str::to_string);
self

View file

@ -1,6 +1,6 @@
use crate::core::TypeInfo;
use crate::html::maud::{Escaper, RenderAttrs};
use crate::{AutoDefault, CowStr, builder_fn, trace, util};
use crate::{AutoDefault, CowStr, builder_impl, trace, util};
use thiserror::Error;
@ -453,9 +453,9 @@ impl PropsOp {
/// }
/// }
///
/// #[builder_impl]
/// impl MyButton {
/// /// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
/// #[builder_fn]
/// pub fn with_prop(mut self, op: PropsOp) -> Self {
/// self.props.alter_prop(op);
/// self
@ -471,6 +471,7 @@ pub struct Props {
extras: HashMap<&'static str, PropsExtra>,
}
#[builder_impl]
impl Props {
/// Crea una colección con un primer atributo ya establecido.
pub fn new(name: impl Into<CowStr>, value: impl Into<CowStr>) -> Self {
@ -485,7 +486,6 @@ impl Props {
// **< Props BUILDER >**************************************************************************
/// Establece el identificador del componente; equivale a `with_prop(PropsOp::set_id(id))`.
#[builder_fn]
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
self.apply_id(id.into().as_ref());
self
@ -494,7 +494,6 @@ impl Props {
/// Modifica el identificador, las clases, los atributos o los valores extra según la operación
/// indicada. El método recomendado para construir cada operación es usar los constructores de
/// [`PropsOp`].
#[builder_fn]
pub fn with_prop(mut self, op: PropsOp) -> Self {
match op {
PropsOp::SetId(value) => {

View file

@ -1,4 +1,4 @@
use crate::{AutoDefault, CowStr, builder_fn};
use crate::{AutoDefault, CowStr, builder_impl};
use std::fmt::{self, Write as _};
@ -53,6 +53,7 @@ pub struct RoutePath {
query: indexmap::IndexMap<String, String>,
}
#[builder_impl]
impl RoutePath {
/// Crea un `RoutePath` a partir de un *path* inicial.
///
@ -72,7 +73,6 @@ impl RoutePath {
///
/// Un `value` vacío no se distingue de [`with_flag()`](Self::with_flag): ambos se renderizan
/// como `?key`, sin `=`.
#[builder_fn]
pub fn with_param(mut self, key: impl Into<String>, value: impl AsRef<str>) -> Self {
self.query
.insert(key.into(), Self::encode_query_value(value.as_ref()));
@ -80,7 +80,6 @@ impl RoutePath {
}
/// Añade o sustituye un *flag* sin valor, por ejemplo `?debug`.
#[builder_fn]
pub fn with_flag(mut self, flag: impl Into<String>) -> Self {
self.query.insert(flag.into(), String::new());
self