pub struct LocatedValue { /* private fields */ }Expand description
A Value with its Location and an optional Comment.
Fields are private; build with LocatedValue::new and access through the provided
accessor methods. Display is compact by default; use {value:#} for a multiline dump
with @source:resource:line:column on the first line.
use tanzim_value::{LocatedValue, Location, Value};
let location = Location::at("env", "PORT", None, None, None);
let located = LocatedValue::new(Value::Int(8080), location);
assert_eq!(located.value().as_int(), Some(8080));
assert_eq!(located.location().source_name(), "env");
assert_eq!(format!("{located}"), "8080");Implementations§
Source§impl LocatedValue
impl LocatedValue
Sourcepub fn new(
value: impl Into<Value>,
location: impl Into<Location>,
) -> LocatedValue
pub fn new( value: impl Into<Value>, location: impl Into<Location>, ) -> LocatedValue
Create a located value with an empty (default) comment.
Sourcepub fn into_value(self) -> Value
pub fn into_value(self) -> Value
Consume this located value, discarding location and comment, and return the Value.
Sourcepub fn with_value(self, value: impl Into<Value>) -> LocatedValue
pub fn with_value(self, value: impl Into<Value>) -> LocatedValue
Builder: replace the wrapped value.
Sourcepub fn location_mut(&mut self) -> &mut Location
pub fn location_mut(&mut self) -> &mut Location
Mutable access to the Location.
Sourcepub fn with_location(self, location: impl Into<Location>) -> LocatedValue
pub fn with_location(self, location: impl Into<Location>) -> LocatedValue
Builder: replace the location.
Sourcepub fn set_location(&mut self, location: impl Into<Location>)
pub fn set_location(&mut self, location: impl Into<Location>)
In-place setter for the location.
Sourcepub fn comment_mut(&mut self) -> &mut Comment
pub fn comment_mut(&mut self) -> &mut Comment
Mutable access to the Comment.
Sourcepub fn with_comment(self, comment: Comment) -> LocatedValue
pub fn with_comment(self, comment: Comment) -> LocatedValue
Builder: replace the comment.
Sourcepub fn set_comment(&mut self, comment: Comment)
pub fn set_comment(&mut self, comment: Comment)
In-place setter for the comment.
Trait Implementations§
Source§impl AsRef<Value> for LocatedValue
impl AsRef<Value> for LocatedValue
Source§impl Clone for LocatedValue
impl Clone for LocatedValue
Source§fn clone(&self) -> LocatedValue
fn clone(&self) -> LocatedValue
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LocatedValue
impl Debug for LocatedValue
Source§impl Display for LocatedValue
impl Display for LocatedValue
Source§impl PartialEq for LocatedValue
impl PartialEq for LocatedValue
impl StructuralPartialEq for LocatedValue
Auto Trait Implementations§
impl Freeze for LocatedValue
impl RefUnwindSafe for LocatedValue
impl Send for LocatedValue
impl Sync for LocatedValue
impl Unpin for LocatedValue
impl UnsafeUnpin for LocatedValue
impl UnwindSafe for LocatedValue
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