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

Cargo features user experience #627

Open
AlexanderEkdahl opened this issue Jun 9, 2024 · 2 comments
Open

Cargo features user experience #627

AlexanderEkdahl opened this issue Jun 9, 2024 · 2 comments
Labels
A-objc2 Affects the `objc2`, `objc-sys` and/or `objc2-encode` crates question Further information is requested

Comments

@AlexanderEkdahl
Copy link
Contributor

AlexanderEkdahl commented Jun 9, 2024

As I mentioned earlier, excellent work on these libraries and generators!

That said, I find it frustrating to have to specify the feature for every class I want to use (objc2-metal has 61 features). Should features be enabled by default and libraries that want to reduce code only specify the functionality they need?

I understand that this might be necessary when one crate extends the functionality of another.

Is there a Cargo feature to enable every feature of a crate?

@madsmtm madsmtm added question Further information is requested A-objc2 Affects the `objc2`, `objc-sys` and/or `objc2-encode` crates labels Jun 9, 2024
@madsmtm
Copy link
Owner

madsmtm commented Jun 9, 2024

That said, I find it frustrating to have to specify the feature for every class I want to use (objc2-metal has 61 features). Should features be enabled by default and libraries that want to reduce code only specify the functionality they need?

Hmm, I guess they could all be enabled by default, though it really is a lot of code that's being compiled (objc2-foundation takes 4.5s and objc2-app-kit 9s on my fairly new Mac, a lot more on my older machine),

Is there a Cargo feature to enable every feature of a crate?

Yes there is, it's called all, and is documented in here. Please tell me how to improve the documentation such that you didn't have to ask this question (not that I mind, it's just unfortunate that you had to spend time doing so ;) ). Though now that I'm saying it, a tutorial that shows using "all" to begin with, and then narrows it down later on, would probably do the trick.

@AlexanderEkdahl
Copy link
Contributor Author

Oh, I had no idea about the "magic string" "all". That certainly solves the problem.

Personally I don't mind waiting 9 seconds for something to compile if it saves me 30 minutes of debugging/enabling features. However, I can see how having the capability to turn features on/off is beneficial (especially for libraries). I would expect the linker to remove the unused code but that may not be enabled by default?

Please tell me how to improve the documentation such that you didn't have to ask this question

I was copy-pasting the objc2-metal example to get up-and-running. I'm not sure where it would be natural to introduce the "all" feature as I do believe it is a good starting point for someone who wants to get up and running with an Apple library from Rust.

Maybe a new section in the main README.md that introduces the objc-* crates or in the minimal Readme found on the crates.io documentation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-objc2 Affects the `objc2`, `objc-sys` and/or `objc2-encode` crates question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants