Struct ion_rs::element::builders::SequenceBuilder
source · pub struct SequenceBuilder { /* private fields */ }
Expand description
Constructs Sequence, List, and SExp values incrementally.
Building a Sequence:
use ion_rs::element::{Element, Sequence};
let actual: Sequence = Sequence::builder().push(1).push(true).push("foo").build();
let expected: Sequence = Sequence::new([
Element::integer(1),
Element::boolean(true),
Element::string("foo"),
]);
assert_eq!(actual, expected);
Building a List:
use ion_rs::element::{Element, List, Sequence};
let actual: List = Sequence::builder()
.push(1)
.push(true)
.push("foo")
.build_list();
let expected: List = List(Sequence::new([
Element::integer(1),
Element::boolean(true),
Element::string("foo"),
]));
assert_eq!(actual, expected);
Building a SExp:
use ion_rs::element::{Element, SExp, Sequence};
let actual: SExp = Sequence::builder()
.push(1)
.push(true)
.push("foo")
.build_sexp();
let expected: SExp = SExp(Sequence::new([
Element::integer(1),
Element::boolean(true),
Element::string("foo"),
]));
assert_eq!(actual, expected);
Implementations§
source§impl SequenceBuilder
impl SequenceBuilder
sourcepub fn push<E: Into<Element>>(self, element: E) -> Self
pub fn push<E: Into<Element>>(self, element: E) -> Self
Adds the provided element to the end of the Sequence
being constructed.
sourcepub fn remove(self, index: usize) -> Self
pub fn remove(self, index: usize) -> Self
Removes the element at the specified position from the Sequence
being constructed.
If the index is out of bounds, this method will panic.
sourcepub fn build_list(self) -> List
pub fn build_list(self) -> List
Builds a List
with the previously specified elements.
sourcepub fn build_sexp(self) -> SExp
pub fn build_sexp(self) -> SExp
Builds a SExp
with the previously specified elements.
Auto Trait Implementations§
impl RefUnwindSafe for SequenceBuilder
impl Send for SequenceBuilder
impl Sync for SequenceBuilder
impl Unpin for SequenceBuilder
impl UnwindSafe for SequenceBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more