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

Adding support for int and bool EnumProperties #259

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ejmount
Copy link

@ejmount ejmount commented Mar 13, 2023

What it says on the tin. I was looking for this functionality for my own project and found stubs for it, so I've filled in the functionality and updated tests/docs accordingly. cargo test comes back all green after my changes.

Copy link
Owner

@Peternator7 Peternator7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really great, and I know a couple have people have asked about this feature. Just a couple minor structure things and I think we can get this merged.

fn get_int(&self, _prop: &str) -> Option<usize> {
Option::None
}
fn get_int(&self, prop: &str) -> Option<usize>;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_usize is probably a more future-proof name

Copy link
Author

@ejmount ejmount Apr 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree and I'm happy to make that change, but I also thought it'd be worth mentioning that while it'll be more future proof, it's also technically a breaking change. I'd be immensely surprised if any real code got broken, but I just wanted to check you're ok with that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I jinxed myself by saying earlier nothing would break, because there seems to be an odd dependency between strum_macros and a previous version of the main package. I've made the change and updated the Cargo.toml to use the local version, which solved the issue.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ejmount, sorry for the delay getting back to you. I've been out of town for a few weeks. I missed that I had stubbed that method out at some point in the past. If you're still interested in completing this, here's what we can do. I can publish a new version of strum (not macros) with an updated trait definition then we can rebase your changes onto the new version.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it sounds like that's still not supported, so it'd be great if you could publish a new version to make that update.

strum_macros/src/helpers/metadata.rs Outdated Show resolved Hide resolved
@@ -26,4 +26,4 @@ rustversion = "1.0"
syn = { version = "1.0", features = ["parsing", "extra-traits"] }

[dev-dependencies]
strum = "0.24"
strum = { path = "../strum" }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe you can publish to crates.io with a path dependency.

@ejmount
Copy link
Author

ejmount commented Sep 18, 2024

So this came back to my attention recently so I've rebased it against the current release and resolved conflicts. I had another look at the dependency issue, and as far as I can tell everything works correctly if the name remains get_int, it's only trying to change the name that runs into compatibility issues.

The version I've uploaded just now supports ints and bools and passes local tests, and IMO would be ready to merge if you're OK with get_int having a suboptimal name. I'm still fine with changing it if you make a new release to do so, but I'd think it very unlikely that the exact type of integer is going to be important for most use cases, so it wouldn't cause ambiguity in practice.

I'm not sure why the CI tests are failing on some platforms and not others, but the issue doesn't appear to relate to this change - has the MSRV changed since the pipeline was last updated?

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

Successfully merging this pull request may close these issues.

2 participants