Skip to content

Can we use macro for a public api method? #14

@Syaw0

Description

@Syaw0

we have a lot of duplication implementation for a method in StyledText;

    /// Sets the `bright_white` color to the input text.
    ///
    /// # Example:
    /// ```
    /// use vitalux::styled;
    /// let styled_text = styled("The present is all we have to live in . . . or to lose.").bright_white().paint();
    /// ```
    pub fn bright_white(&mut self) -> &mut Self {
        self.start_styles.push(basic_color::BRIGHT_WHITE);
        self
    }

    // Formatters

    /// Sets the `reset` effect to the input text.
    ///
    /// # Example:
    /// ```
    /// use vitalux::styled;
    /// let styled_text = styled("The present is all we have to live in . . . or to lose.").red().reset().paint();
    /// ```
    /// ** this will reset all the effects, colors and formatters that are called before this**
    /// so in the top example the red color will never applied to the input text
    pub fn reset(&mut self) -> &mut Self {
        self.start_styles.push(formatter::RESET);
        self
    }

what if we use macro to create these implementation for us?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestquestionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions