Skip to content

Provide IntoId trait for ID extraction #5

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

Merged
merged 2 commits into from
Apr 21, 2025
Merged

Provide IntoId trait for ID extraction #5

merged 2 commits into from
Apr 21, 2025

Conversation

JR-1991
Copy link
Member

@JR-1991 JR-1991 commented Mar 12, 2025

This PR introduces a QoL improvement trait called IntoID, which provides a standardized interface to extract relevant IDs for re-use in other parts of the code. The implementation now allows imp IntoId<...> types to either accept a raw ID string or a struct that has implemented the trait.

Example

// Create a compartment
    let compartment = model
        .build_compartment("cytosol")
        .name("cytosol")
        .unit(&ml.id())
        .build();

    // Create the ethanol species
    let ethanol = model
        .build_species("ethanol")
        .name("Ethanol")
        .compartment(&compartment) // We can now pass the entire instance or `compartment.id()`
        .initial_concentration(0.5)
        .unit(&mole.id())
        .has_only_substance_units(false)
        .build();

@JR-1991 JR-1991 added the enhancement New feature or request label Mar 12, 2025
@JR-1991 JR-1991 self-assigned this Mar 12, 2025
@JR-1991 JR-1991 added this to EnzymeML Mar 12, 2025
@JR-1991 JR-1991 merged commit 9ade76a into master Apr 21, 2025
3 checks passed
@github-project-automation github-project-automation bot moved this to Done in EnzymeML Apr 21, 2025
@JR-1991 JR-1991 deleted the into-id branch April 21, 2025 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant