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

Make AttrValue's tokens() and atom() return or panic #7479

Closed
nox opened this issue Aug 31, 2015 · 4 comments
Closed

Make AttrValue's tokens() and atom() return or panic #7479

nox opened this issue Aug 31, 2015 · 4 comments

Comments

@nox
Copy link
Member

@nox nox commented Aug 31, 2015

There is no reason an AttrValue should change variant once set, so we should refactor the API accordingly. This allows us to have better consistent panic messages in such cases.

@psdh
Copy link
Contributor

@psdh psdh commented Sep 1, 2015

Is this what you intend

match *self {`
    AttrValue::Atom(ref value) => Some(value),
    _ => panic!(),
}
@nox
Copy link
Member Author

@nox nox commented Sep 1, 2015

@psdh Yes.

@nox
Copy link
Member Author

@nox nox commented Sep 1, 2015

Actually no, without the Some(_). And with a message passed to panic!().

@tafia
Copy link
Contributor

@tafia tafia commented Sep 2, 2015

What is the reason to prefer panic over Result ?

bors-servo pushed a commit that referenced this issue Sep 2, 2015
make AttrVal tokens() and atom() return or panic

Fixes #7479

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7511)
<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this issue Sep 2, 2015
make AttrVal tokens() and atom() return or panic

Fixes #7479

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7511)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.