Skip to content

Commit b0f7a67

Browse files
committed
0.8.0 remove deprecated methods #34
1 parent 8e3b796 commit b0f7a67

File tree

3 files changed

+1
-129
lines changed

3 files changed

+1
-129
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "json"
3-
version = "0.7.4"
3+
version = "0.8.0"
44
authors = ["Maciej Hirsz <[email protected]>"]
55
description = "JSON implementation in Rust"
66
repository = "https://github.com/maciejhirsz/json-rust"

src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,6 @@ pub fn from<T>(value: T) -> JsonValue where T: Into<JsonValue> {
264264
value.into()
265265
}
266266

267-
#[deprecated(since="0.5.0", note="Use `value.dump(0)` instead")]
268-
pub fn stringify_ref(root: &JsonValue) -> String {
269-
root.dump()
270-
}
271-
272267
/// Pretty prints out the value as JSON string.
273268
pub fn stringify<T>(root: T) -> String where T: Into<JsonValue> {
274269
let root: JsonValue = root.into();

src/value.rs

Lines changed: 0 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ impl JsonValue {
4949
JsonValue::Array(Vec::new())
5050
}
5151

52-
/// Checks if the value stored matches `other`.
53-
#[deprecated(since="0.7.0", note="Use `value == other` instead")]
54-
pub fn is<T>(&self, other: T) -> bool where T: Into<JsonValue> {
55-
*self == other.into()
56-
}
57-
5852
pub fn is_string(&self) -> bool {
5953
match *self {
6054
JsonValue::String(_) => true,
@@ -116,29 +110,13 @@ impl JsonValue {
116110
}
117111
}
118112

119-
#[deprecated(since="0.6.1", note="Use `as_str` instead")]
120-
pub fn as_string(&self) -> JsonResult<&String> {
121-
match *self {
122-
JsonValue::String(ref value) => Ok(value),
123-
_ => Err(JsonError::wrong_type("String"))
124-
}
125-
}
126-
127113
pub fn as_str(&self) -> Option<&str> {
128114
match *self {
129115
JsonValue::String(ref value) => Some(value.as_ref()),
130116
_ => None
131117
}
132118
}
133119

134-
#[deprecated(since="0.6.1", note="Use `as_f64` instead")]
135-
pub fn as_number(&self) -> JsonResult<&f64> {
136-
match *self {
137-
JsonValue::Number(ref value) => Ok(value),
138-
_ => Err(JsonError::wrong_type("Number"))
139-
}
140-
}
141-
142120
pub fn as_f64(&self) -> Option<f64> {
143121
match *self {
144122
JsonValue::Number(ref value) => Some(*value),
@@ -197,75 +175,6 @@ impl JsonValue {
197175
}
198176
}
199177

200-
#[deprecated(since="0.6.1", note="Use `as_bool` instead")]
201-
pub fn as_boolean(&self) -> JsonResult<&bool> {
202-
match *self {
203-
JsonValue::Boolean(ref value) => Ok(value),
204-
_ => Err(JsonError::wrong_type("Boolean"))
205-
}
206-
}
207-
208-
/// Works on `JsonValue::Object` - create or override key with value.
209-
#[must_use]
210-
#[deprecated(since="0.6.0", note="Use `object[key] = value.into()` instead")]
211-
pub fn put<T>(&mut self, key: &str, value: T) -> JsonResult<()>
212-
where T: Into<JsonValue> {
213-
match *self {
214-
JsonValue::Object(ref mut btree) => {
215-
btree.insert(key.into(), value.into());
216-
Ok(())
217-
},
218-
_ => Err(JsonError::wrong_type("Object"))
219-
}
220-
}
221-
222-
/// Works on `JsonValue::Object` - get a reference to a value behind key.
223-
/// For most purposes consider using `object[key]` instead.
224-
#[deprecated(since="0.6.0", note="Use `object[key]` instead")]
225-
pub fn get(&self, key: &str) -> JsonResult<&JsonValue> {
226-
match *self {
227-
JsonValue::Object(ref btree) => match btree.get(key) {
228-
Some(value) => Ok(value),
229-
_ => Err(JsonError::undefined(key))
230-
},
231-
_ => Err(JsonError::wrong_type("Object"))
232-
}
233-
}
234-
235-
/// Works on `JsonValue::Object` - get a mutable reference to a value behind
236-
/// the key.
237-
#[deprecated(since="0.6.0", note="Use `object[key]` instead")]
238-
pub fn get_mut(&mut self, key: &str) -> JsonResult<&mut JsonValue> {
239-
match *self {
240-
JsonValue::Object(ref mut btree) => match btree.get_mut(key) {
241-
Some(value) => Ok(value),
242-
_ => Err(JsonError::undefined(key))
243-
},
244-
_ => Err(JsonError::wrong_type("Object"))
245-
}
246-
}
247-
248-
/// Attempts to get a mutable reference to the value behind a key on an
249-
/// object. If the reference doesn't exists, it will be created and
250-
/// assigned a null. If `self` is not an object, an empty object with
251-
/// null key will be created.
252-
#[deprecated(since="0.6.0", note="Use `object[key]` instead")]
253-
pub fn with(&mut self, key: &str) -> &mut JsonValue {
254-
if !self.is_object() {
255-
*self = JsonValue::new_object();
256-
}
257-
258-
match *self {
259-
JsonValue::Object(ref mut btree) => {
260-
if !btree.contains_key(key) {
261-
btree.insert(key.to_string(), JsonValue::Null);
262-
}
263-
btree.get_mut(key).unwrap()
264-
},
265-
_ => unreachable!()
266-
}
267-
}
268-
269178
/// Works on `JsonValue::Array` - pushes a new value to the array.
270179
#[must_use]
271180
pub fn push<T>(&mut self, value: T) -> JsonResult<()>
@@ -290,38 +199,6 @@ impl JsonValue {
290199
}
291200
}
292201

293-
/// Works on `JsonValue::Array` - gets a reference to a value at index.
294-
/// For most purposes consider using `array[index]` instead.
295-
#[deprecated(since="0.6.0", note="Use `array[index]` instead")]
296-
pub fn at(&self, index: usize) -> JsonResult<&JsonValue> {
297-
match *self {
298-
JsonValue::Array(ref vec) => {
299-
if index < vec.len() {
300-
Ok(&vec[index])
301-
} else {
302-
Err(JsonError::ArrayIndexOutOfBounds)
303-
}
304-
},
305-
_ => Err(JsonError::wrong_type("Array"))
306-
}
307-
}
308-
309-
/// Works on `JsonValue::Array` - gets a mutable reference to a value
310-
/// at index.
311-
#[deprecated(since="0.6.0", note="Use `array[index]` instead")]
312-
pub fn at_mut(&mut self, index: usize) -> JsonResult<&mut JsonValue> {
313-
match *self {
314-
JsonValue::Array(ref mut vec) => {
315-
if index < vec.len() {
316-
Ok(&mut vec[index])
317-
} else {
318-
Err(JsonError::ArrayIndexOutOfBounds)
319-
}
320-
},
321-
_ => Err(JsonError::wrong_type("Array"))
322-
}
323-
}
324-
325202
/// Works on `JsonValue::Array` - checks if the array contains a value
326203
pub fn contains<T>(&self, item: T) -> bool where T: Into<JsonValue> {
327204
match *self {

0 commit comments

Comments
 (0)