Skip to content

Feature Request: const creation of Url #1042

Open
@poliorcetics

Description

@poliorcetics

I have a program with three (3) default Urls used in multiple places.

Right now, I'm doing CONSTANT_1.parse().expect("statically known url is invalid") everytime and just relying on tests to catch mistakes (not that they have ever changed but still, I don't want to leave it to chance).

I could use a LazyCell and do the expect dance once but that means I still have to do expect

Is it possible to either modify Url or have a ConstUrl::new("static str").into() -> Url ?

My personal use case is something like http(s)://<ip|domain>:<port> so I would be fine with a first version explicitly refusing to support more than this, but I can understand that being too limiting for other use cases

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