🎨 [macros] Redefine #[fn_builder] con coherencia
La macro genera automáticamente un método "alter_", que modifica la instancia actual usando "&mut self", y redefine el método "with_" para delegar la lógica en el nuevo método "alter_".
This commit is contained in:
parent
4db4d791a5
commit
febb9bc9cb
13 changed files with 176 additions and 137 deletions
|
|
@ -42,13 +42,13 @@ impl HljsSnippet {
|
|||
// Hljs BUILDER.
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_language(&mut self, language: HljsLang) -> &mut Self {
|
||||
pub fn with_language(mut self, language: HljsLang) -> Self {
|
||||
self.language = language;
|
||||
self
|
||||
}
|
||||
|
||||
#[fn_builder]
|
||||
pub fn alter_snippet(&mut self, snippet: impl Into<String>) -> &mut Self {
|
||||
pub fn with_snippet(mut self, snippet: impl Into<String>) -> Self {
|
||||
self.snippet = snippet.into().trim().to_string();
|
||||
self
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue