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

Rename json::List to json::Array #19114

Merged
merged 3 commits into from
Nov 21, 2014
Merged

Rename json::List to json::Array #19114

merged 3 commits into from
Nov 21, 2014

Conversation

frewsxcv
Copy link
Member

Fixes #19010

/// Returns true if the Json value is a List. Returns false otherwise.
pub fn is_list<'a>(&'a self) -> bool {
self.as_list().is_some()
/// Returns true if the Json value is a Array. Returns false otherwise.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"an Array"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

English is difficult

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in frewsxcv@ef5acff

Object(JsonObject),
Null,
}

pub type JsonList = Vec<Json>;
pub type JsonArray = Vec<Json>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Json prefixes of these aliases are unneeded since we have a snapshot, the re-exports of Json variants won't conflict in the type namespace (as the non-re-exported variants would, previously).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel as though that is a separate (but valid) task unrelated to mine and would be better off in a separate pull request

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, we can leave that change for a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eddyb I unprefixed the type aliases and it appears they are conflicting with the variants. Am I doing something wrong here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to be a bit careful in how you refer to the typedef:

pub enum Json {
    Array(json::Array),
    ...
}

pub type Array = Vec<Json>;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we're planning on leaving them around for 1.0, but I am not the API czar. cc @aturon

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened a PR #19224

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sfackler @frewsxcv I think in most cases the re-exports should be dropped, yes. I should probably write up an explicit conventions RFC on this topic. Are there any cases where you think re-exporting a variant is warranted?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of any off the top of my head.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least for this JSON module, I can't think of any reason to keep the re-exports

@bstrie
Copy link
Contributor

bstrie commented Nov 20, 2014

Thanks, and welcome. :)

bors added a commit that referenced this pull request Nov 21, 2014
@bors bors closed this Nov 21, 2014
@bors bors merged commit ef5acff into rust-lang:master Nov 21, 2014
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Nov 27, 2014
Addressing the issues brought up in [this thread](rust-lang#19114 (comment))

This pull request:

* Unpublicizes reexports
* Renames type aliases:
 * `json::JsonArray` ☞ `json::Array`
 * `json::JsonObject` ☞ `json::Object`
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.

JSON 'List' name inconsistent with JSON specification
6 participants