servo / servo/rust-url

Return Result<{Self,&Self,&mut Self}, _> instead of Result<(), _> to allow method chaining

Open
#375 6 comments 0 reactions 1 assignee View on GitHub

@nox is already working on this.

Since Jul 18, 2019.

breaking-change
Dominant language
Rust
Stars
1.6k
Forks
406
PR merge metrics
No merged PRs in 30d

Description

I'm working on the issue #299 right now and I saw some methods return Result<(), ()>, the issue I mentionned is about making them return a ParseResult<()>, but wouldn't it be better if they returned ParseResult<Self>, in order to allow method chaining with ? or (old) unwrap()?

This would actually be useful mainly for setters, I set up an actual list of them:

  1. #set_href
  2. HostInternal#serialize<S> (part of serde crate, but I think can be replaced)
  3. (IDNA) #domain_to_unicode
  4. Url#set_port
  5. Url#set_ip_host
  6. Url#set_password
  7. Url#set_username
  8. Url#set_scheme

Could work on this, be I need to be validated by someone before.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.