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

[v0.1.14 blocker] Should Port<'a> have a different name? #263

Closed
seanmonstar opened this issue Oct 18, 2018 · 2 comments
Closed

[v0.1.14 blocker] Should Port<'a> have a different name? #263

seanmonstar opened this issue Oct 18, 2018 · 2 comments
Labels
A-uri Area: Uri and parts S-feature Severity: feature. This adds something new.

Comments

@seanmonstar
Copy link
Member

In #173, which is now in master, we added a Port<'a>, which includes not only the u16 port number, but also the &str of the port. This allows efficiently asking for the "port" part of a Uri as a string, without needing to get a u16 and allocate a new String by calling port_num.to_string().

In #219, also in master, a uri::Builder was introduced. The idea is to allow for easily building up a Uri from fallible parts. It seems like it could be nice to add a port setter, which takes a generic P where Port: HttpTryFrom<P>. This would allow a user to pass a u16, a &str, or a Port from a different Uri.

However, with Port<'a>, adding this API to uri::Builder would be impossible. So, should Port<'a> be renamed to something else? It'd be useful to find other precedents, but until they are found and listed, if renaming is desired, some possible names are:

  • PortRef<'a>
  • PortSlice<'a>
  • PortPart<'a>

As this type isn't released yet (only on master), and it affects whether we can add to the uri::Builder API, I believe finding an answer should block releasing v0.1.14.

@carllerche
Copy link
Collaborator

carllerche commented Oct 18, 2018

What about:

struct Port<T = Bytes> {
   parsed: u16,
   repr: T,
}

@seanmonstar
Copy link
Member Author

That could work nicely.

seanmonstar added a commit that referenced this issue Oct 18, 2018
seanmonstar added a commit that referenced this issue Oct 18, 2018
@seanmonstar seanmonstar added S-feature Severity: feature. This adds something new. A-uri Area: Uri and parts labels Oct 18, 2018
seanmonstar added a commit that referenced this issue Oct 18, 2018
seanmonstar added a commit that referenced this issue Oct 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-uri Area: Uri and parts S-feature Severity: feature. This adds something new.
Projects
None yet
Development

No branches or pull requests

2 participants