Skip to content

RUST-1508 Implement conversion traits between strings and ObjectId #376

Open
@clarkmcc

Description

@clarkmcc

I'd like to be able to do things like

fn query<K: TryInto<ObjectId>>(key: K) {}

fn main() {
    let key = "000000000000000000000000";
    query(key);

    let key = String::from("000000000000000000000000");
    query(key);

    let key = ObjectId::new();
    query(key);
}

but it doesn't seem like the necessary conversion traits have been implemented. I'm not a Rust expert and so I cannot speak to what the solution is, but it would be really convenient to be able to both pass ObjectIds and types that can be turned into ObjectIds.

Metadata

Metadata

Assignees

Labels

tracked-in-jiraTicket filed in Mongo's Jira system

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions