Allow specifying a module path to the phf crate for codegen#81
Merged
sfackler merged 1 commit intorust-phf:masterfrom Apr 25, 2016
Merged
Allow specifying a module path to the phf crate for codegen#81sfackler merged 1 commit intorust-phf:masterfrom
sfackler merged 1 commit intorust-phf:masterfrom
Conversation
| /// A builder for the `phf::Set` type. | ||
| pub struct Set<T> { | ||
| map: Map<T>, | ||
| path: String, |
Collaborator
There was a problem hiding this comment.
You can probably just look at the path of the Map instead of also tracking this here.
Collaborator
|
Hey, sorry for missing this until now. Seems reasonable other than one comment. |
a555b51 to
4a7999e
Compare
Contributor
Author
|
Rebased and made suggested change |
Collaborator
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
At the most basic level, this means you can use
phf_codegenif you've got something likeextern crate phf as __some_phf_alias;. More usefully, this PR permits crates to add their own codegen on top ofphfwithout requiring all consuming crates to explicitly depend onphf.Concretely, I want this for servo/string-cache#136. See https://github.com/servo/string-cache/pull/136/files#diff-f5597aa77bf5eea303399f7125c5a0adR10 and the current hack I'm resorting to at https://github.com/servo/string-cache/pull/136/files#diff-141f99248469f8dc2a1daf108bbf23c1R71 (relies on the next string being written to start with
::phf).To briefly explain the problem: it's a given that consumers of
string_cache_codegenwill need to depend onstring_cache. However, ifstring_cache_codegengenerates a vanilla phf map, consumers ofstring_cache_codegenalso need to addphfto their own Cargo.toml and addextern crate phf;. Exposingphfunder thestring_cachecrate sidesteps this inconvenience by using the existingstring_cachedependency (and means you don't have to upgradestring_cacheandphfin lockstep).(I'm open to suggestions for better ways to do this by the way)