@@ -72,49 +72,61 @@ impl Item {
72
72
index. index_mut ( self )
73
73
}
74
74
75
- /// Casts `self` to value.
75
+ /// Casts `self` to [`Value`]
76
76
pub fn as_value ( & self ) -> Option < & Value > {
77
77
match * self {
78
78
Item :: Value ( ref v) => Some ( v) ,
79
79
_ => None ,
80
80
}
81
81
}
82
- /// Casts `self` to table.
82
+ /// Casts `self` to [`Table`]
83
+ ///
84
+ /// <div class="warning">
85
+ ///
86
+ /// To operate on both [`Table`]s and [`InlineTable`]`s, see [`Item::as_table_like`]
87
+ ///
88
+ /// </div>
83
89
pub fn as_table ( & self ) -> Option < & Table > {
84
90
match * self {
85
91
Item :: Table ( ref t) => Some ( t) ,
86
92
_ => None ,
87
93
}
88
94
}
89
- /// Casts `self` to array of tables.
95
+ /// Casts `self` to [`ArrayOfTables`]
90
96
pub fn as_array_of_tables ( & self ) -> Option < & ArrayOfTables > {
91
97
match * self {
92
98
Item :: ArrayOfTables ( ref a) => Some ( a) ,
93
99
_ => None ,
94
100
}
95
101
}
96
- /// Casts `self` to mutable value .
102
+ /// Casts `self` to mutable [`Value`] .
97
103
pub fn as_value_mut ( & mut self ) -> Option < & mut Value > {
98
104
match * self {
99
105
Item :: Value ( ref mut v) => Some ( v) ,
100
106
_ => None ,
101
107
}
102
108
}
103
- /// Casts `self` to mutable table.
109
+ /// Casts `self` to mutable [`Table`]
110
+ ///
111
+ /// <div class="warning">
112
+ ///
113
+ /// To operate on both [`Table`]s and [`InlineTable`]`s, see [`Item::as_table_like_mut`]
114
+ ///
115
+ /// </div>
104
116
pub fn as_table_mut ( & mut self ) -> Option < & mut Table > {
105
117
match * self {
106
118
Item :: Table ( ref mut t) => Some ( t) ,
107
119
_ => None ,
108
120
}
109
121
}
110
- /// Casts `self` to mutable array of tables.
122
+ /// Casts `self` to mutable [`ArrayOfTables`]
111
123
pub fn as_array_of_tables_mut ( & mut self ) -> Option < & mut ArrayOfTables > {
112
124
match * self {
113
125
Item :: ArrayOfTables ( ref mut a) => Some ( a) ,
114
126
_ => None ,
115
127
}
116
128
}
117
- /// Casts `self` to value.
129
+ /// Casts `self` to [`Value`]
118
130
pub fn into_value ( self ) -> Result < Value , Self > {
119
131
match self {
120
132
Item :: None => Err ( self ) ,
@@ -135,15 +147,21 @@ impl Item {
135
147
let other = other. into_value ( ) . map ( Item :: Value ) . unwrap_or ( Item :: None ) ;
136
148
* self = other;
137
149
}
138
- /// Casts `self` to table.
150
+ /// Casts `self` to [`Table`]
151
+ ///
152
+ /// <div class="warning">
153
+ ///
154
+ /// This does not include [`InlineTable`]s
155
+ ///
156
+ /// </div>
139
157
pub fn into_table ( self ) -> Result < Table , Self > {
140
158
match self {
141
159
Item :: Table ( t) => Ok ( t) ,
142
160
Item :: Value ( Value :: InlineTable ( t) ) => Ok ( t. into_table ( ) ) ,
143
161
_ => Err ( self ) ,
144
162
}
145
163
}
146
- /// Casts `self` to array of tables.
164
+ /// Casts `self` to [`ArrayOfTables`]
147
165
pub fn into_array_of_tables ( self ) -> Result < ArrayOfTables , Self > {
148
166
match self {
149
167
Item :: ArrayOfTables ( a) => Ok ( a) ,
@@ -177,15 +195,21 @@ impl Item {
177
195
} ;
178
196
* self = other;
179
197
}
180
- /// Returns true if `self` is a value.
198
+ /// Returns true if `self` is a [`Value`]
181
199
pub fn is_value ( & self ) -> bool {
182
200
self . as_value ( ) . is_some ( )
183
201
}
184
- /// Returns true if `self` is a table.
202
+ /// Returns true if `self` is a [`Table`]
203
+ ///
204
+ /// <div class="warning">
205
+ ///
206
+ /// To operate on both [`Table`]s and [`InlineTable`]`s, see [`Item::is_table_like`]
207
+ ///
208
+ /// </div>
185
209
pub fn is_table ( & self ) -> bool {
186
210
self . as_table ( ) . is_some ( )
187
211
}
188
- /// Returns true if `self` is an array of tables.
212
+ /// Returns true if `self` is an [`ArrayOfTables`]
189
213
pub fn is_array_of_tables ( & self ) -> bool {
190
214
self . as_array_of_tables ( ) . is_some ( )
191
215
}
0 commit comments