Trait ion_rs::element::IntoAnnotatedElement
source · pub trait IntoAnnotatedElement: Into<Value> {
// Provided method
fn with_annotations<I: IntoAnnotations>(self, annotations: I) -> Element { ... }
}
Expand description
Allows types that can be converted into an Ion Value to also specify annotations, producing an Element.
use ion_rs::element::{Element, IntoAnnotatedElement, Value};
use ion_rs::ion_list;
// Explicit conversion of a Rust bool (`true`) into a `Value`...
let boolean_value: Value = true.into();
// and then into an `Element`...
let mut boolean_element: Element = boolean_value.into();
// and then adding annotations to the `Element`.
boolean_element = boolean_element.with_annotations(["foo", "bar"]);
// Much more concise equivalent leveraging the `IntoAnnotatedElement` trait.
let boolean_element = true.with_annotations(["foo", "bar"]);
Provided Methods§
sourcefn with_annotations<I: IntoAnnotations>(self, annotations: I) -> Element
fn with_annotations<I: IntoAnnotations>(self, annotations: I) -> Element
Converts the value into an Element with the specified annotations.