Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to create Decor instances with optional prefix or suffix #729

Open
oxcabe opened this issue May 10, 2024 · 0 comments
Open

Allow to create Decor instances with optional prefix or suffix #729

oxcabe opened this issue May 10, 2024 · 0 comments

Comments

@oxcabe
Copy link

oxcabe commented May 10, 2024

Description

Having more flexible ways to instantiate Decor could be a good thing. I think it's handy to partially instantiate Decor with either the prefix or the suffix.

Example

I want to do this:

let key = Key::new("hello").with_leaf_decor(Decor::new(None, "world")); // "hello" key with "world" decor suffix

Or even something similar to this:

let key = Key::new("hello").with_leaf_decor(Decor::new_suffix("world")); // "hello" key with "world" decor suffix

But instead, I have to do this:

let mut decor = Decor::new();
decor.set_suffix("world");

let key = Key::new("hello").with_leaf_decor(decor); // "hello" key with "world" decor suffix

Or this (which is possibly wrong but may work sometimes):

let key = Key::new("hello").with_leaf_decor(Decor::new("", "world")); // "hello" key with "world" decor suffix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant