Trait rbatis::OpsIndex[][src]

pub trait OpsIndex<Idx> where
    Idx: ?Sized
{ type Output: ?Sized; fn index(&self, index: Idx) -> &Self::Output; }

Associated Types

The returned type after indexing.

Required methods

Performs the indexing (container[index]) operation.

Panics

May panic if the index is out of bounds.

Implementations on Foreign Types

Index into a rbatis_sql::Value using the syntax value[0] or value["k"].

Returns Value::Null if the type of self does not match the type of the index, for example if the index is a string and self is an array or a number. Also returns Value::Null if the given key does not exist in the map or the given index is not within the bounds of the array.

For retrieving deeply nested values, you should have a look at the Value::pointer method.

Examples
let data = bson!({
    "x": {
        "y": ["z", "zz"]
    }
});

assert_eq!(data["x"]["y"], bson!(["z", "zz"]));
assert_eq!(data["x"]["y"][0], bson!("z"));

assert_eq!(data["a"], bson!(null)); // returns null for undefined values
assert_eq!(data["a"]["b"], bson!(null)); // does not panic

Implementors