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

Unsafe as a feature #4

Closed
nrxus opened this issue Dec 27, 2019 · 5 comments
Closed

Unsafe as a feature #4

nrxus opened this issue Dec 27, 2019 · 5 comments

Comments

@nrxus
Copy link
Owner

nrxus commented Dec 27, 2019

Writing unsafe on every mock is a bit annoying.

What if we added a feature called unsafe or i-know-faux-is-unsafe-so-hush that if turned on exposed the mocking methods as "safe" since the user has already opted-in the unsafety at the crate level.

@TedDriggs
Copy link
Contributor

What if you added reckless_then as a "safe" version of then which just lies about the safety? You can gate the exposure of that method on a crate feature, and that way one crate turning it on won't cause other crates in the dependency graph to experience any behavior changes.

@nrxus
Copy link
Owner Author

nrxus commented Jan 28, 2020

Do you mind linking me documentation on how feature flags poison through cyclic dependencies? My google-fu is failing me.

@TedDriggs
Copy link
Contributor

TedDriggs commented Jan 29, 2020

crate A

[dependencies]
crate-b = { version = "0.1.0", features = ["foo"] }
crate-c = "1.1.0"

crate C

[dependencies]
crate-b = { version = "0.1.0", features = ["baz"] }

At this point, crate A would see both foo and baz features enabled. That's why features are supposed to always be additive, and to avoid being mutually exclusive whenever possible.

@nrxus
Copy link
Owner Author

nrxus commented Jan 29, 2020

Ah!

That makes sense now. Hmm I am not a huge fan of reckless_then but I will consider it as I think of alternatives. I do not think this is a very high priority issue anyway, explicit unsafe will do for now.

@nrxus
Copy link
Owner Author

nrxus commented Apr 9, 2021

faux can now handle a lot more code with safe Rust so this is no longer needed.

@nrxus nrxus closed this as completed Apr 9, 2021
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

No branches or pull requests

2 participants