Remove "item" terminology in favor of "container"

The docs have been using "container" for a long time.
This commit is contained in:
David Tolnay
2017-04-14 15:52:56 -07:00
parent 6d55501dab
commit f9535a4d67
6 changed files with 163 additions and 163 deletions
+6 -6
View File
@@ -11,9 +11,9 @@ use attr;
use check;
use Ctxt;
pub struct Item<'a> {
pub struct Container<'a> {
pub ident: syn::Ident,
pub attrs: attr::Item,
pub attrs: attr::Container,
pub body: Body<'a>,
pub generics: &'a syn::Generics,
}
@@ -43,9 +43,9 @@ pub enum Style {
Unit,
}
impl<'a> Item<'a> {
pub fn from_ast(cx: &Ctxt, item: &'a syn::MacroInput) -> Item<'a> {
let attrs = attr::Item::from_ast(cx, item);
impl<'a> Container<'a> {
pub fn from_ast(cx: &Ctxt, item: &'a syn::MacroInput) -> Container<'a> {
let attrs = attr::Container::from_ast(cx, item);
let mut body = match item.body {
syn::Body::Enum(ref variants) => Body::Enum(enum_from_ast(cx, variants)),
@@ -71,7 +71,7 @@ impl<'a> Item<'a> {
}
}
let item = Item {
let item = Container {
ident: item.ident.clone(),
attrs: attrs,
body: body,
+4 -4
View File
@@ -15,7 +15,7 @@ use std::collections::BTreeSet;
use std::str::FromStr;
// This module handles parsing of `#[serde(...)]` attributes. The entrypoints
// are `attr::Item::from_ast`, `attr::Variant::from_ast`, and
// are `attr::Container::from_ast`, `attr::Variant::from_ast`, and
// `attr::Field::from_ast`. Each returns an instance of the corresponding
// struct. Note that none of them return a Result. Unrecognized, malformed, or
// duplicated attributes result in a span_err but otherwise are ignored. The
@@ -100,7 +100,7 @@ impl Name {
/// Represents container (e.g. struct) attribute information
#[derive(Debug)]
pub struct Item {
pub struct Container {
name: Name,
deny_unknown_fields: bool,
default: Default,
@@ -145,7 +145,7 @@ pub enum EnumTag {
None,
}
impl Item {
impl Container {
/// Extract out the `#[serde(...)]` attributes from an item.
pub fn from_ast(cx: &Ctxt, item: &syn::MacroInput) -> Self {
let mut ser_name = Attr::none(cx, "rename");
@@ -365,7 +365,7 @@ impl Item {
}
};
Item {
Container {
name: Name {
serialize: ser_name.get().unwrap_or_else(|| item.ident.to_string()),
deserialize: de_name.get().unwrap_or_else(|| item.ident.to_string()),
+2 -2
View File
@@ -6,12 +6,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use ast::{Body, Item};
use ast::{Body, Container};
use Ctxt;
/// Cross-cutting checks that require looking at more than a single attrs
/// object. Simpler checks should happen when parsing and building the attrs.
pub fn check(cx: &Ctxt, item: &Item) {
pub fn check(cx: &Ctxt, item: &Container) {
match item.body {
Body::Enum(_) => {
if item.body.has_getter() {