8000 Allow to create `Decor` instances with optional prefix or suffix · Issue #729 · toml-rs/toml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Allow to create Decor instances with optional prefix or suffix #729
Open
@oxcabe

Description

@oxcabe

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0