Skip to content

Conversation

@japaric
Copy link
Contributor

@japaric japaric commented Jun 3, 2014

Let me know if the amount of tests is enough or too much.

@japaric
Copy link
Contributor Author

japaric commented Jun 3, 2014

cc @SimonSapin

@SimonSapin
Copy link
Contributor

Looks good to me. Thanks!

@Sawyer47
Copy link
Contributor

Sawyer47 commented Jun 3, 2014

It probably makes sense to implement it also for &'a mut, for completeness.

@SimonSapin
Copy link
Contributor

@Sawyer47 Don’t impls for &[T] also implicitly apply to &mut [T]?

@japaric
Copy link
Contributor Author

japaric commented Jun 3, 2014

It probably makes sense to implement it also for &'a mut, for completeness.

vec!(1, 2, 3).as_mut_slice().to_json() already works as it is. But perhaps we should also implement ToJson for &str?

@Sawyer47
Copy link
Contributor

Sawyer47 commented Jun 3, 2014

@SimonSapin Honestly I'm not sure. There are separate implementations of Eq, Ord, PartialEq, PartialOrd, Show and Hash for both &'a and &'a mut so I thought the first doesn't imply the second.

@alexcrichton
Copy link
Member

Some traits are explicitly implemented for &mut T so that type itself can satisfy the trait. For example the following would not work with this patch:

&[&mut [1]].to_json()

Because &mut [T] doesn't implement ToJson, you can't satisfy any implementation of ToJson, so it fails to compile. It's probably not worth it to extend to &mut T for now.

@Sawyer47
Copy link
Contributor

Sawyer47 commented Jun 3, 2014

@alexcrichton Thanks, good to know.

bors added a commit that referenced this pull request Jun 3, 2014
Let me know if the amount of tests is enough or too much.
@bors bors closed this Jun 3, 2014
@bors bors merged commit a413d00 into rust-lang:master Jun 3, 2014
@japaric japaric deleted the slice-tojson branch June 3, 2014 21:14
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 5, 2023
…ments, r=Veykril

mbe: fix token conversion for doc comments

fixes rust-lang#14611

when creating token trees for the converted doc comment, we should use the correct span in all places, rather than allowing some to remain unspecified. otherwise, things behave incorrectly.
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

Successfully merging this pull request may close these issues.

5 participants