pub struct ValueWithSpan {
pub value: Value,
pub span: Span,
}
Expand description
Wraps a primitive SQL Value
with its Span
location
§Example: create a ValueWithSpan
from a Value
let value = Value::SingleQuotedString(String::from("endpoint"));
// from line 1, column 1 to line 1, column 7
let span = Span::new(Location::new(1, 1), Location::new(1, 7));
let value_with_span = value.with_span(span);
§Example: create a ValueWithSpan
from a Value
with an empty span
You can call Value::with_empty_span
to create a ValueWithSpan
with an empty span
let value = Value::SingleQuotedString(String::from("endpoint"));
let value_with_span = value.with_empty_span();
assert_eq!(value_with_span.span, Span::empty());
You can also use the From
trait to convert ValueWithSpan
to/from Value
s
let value = Value::SingleQuotedString(String::from("endpoint"));
// converting `Value` to `ValueWithSpan` results in an empty span
let value_with_span: ValueWithSpan = value.into();
assert_eq!(value_with_span.span, Span::empty());
// convert back to `Value`
let value: Value = value_with_span.into();
Fields§
§value: Value
§span: Span
Implementations§
Source§impl ValueWithSpan
impl ValueWithSpan
Sourcepub fn into_string(self) -> Option<String>
pub fn into_string(self) -> Option<String>
If the underlying literal is a string, regardless of quote style, returns the associated string value
Trait Implementations§
Source§impl Clone for ValueWithSpan
impl Clone for ValueWithSpan
Source§fn clone(&self) -> ValueWithSpan
fn clone(&self) -> ValueWithSpan
Returns a copy of the value. Read more
1.0.0 · 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 ValueWithSpan
impl Debug for ValueWithSpan
Source§impl<'de> Deserialize<'de> for ValueWithSpan
impl<'de> Deserialize<'de> for ValueWithSpan
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for ValueWithSpan
impl Display for ValueWithSpan
Source§impl From<Value> for ValueWithSpan
impl From<Value> for ValueWithSpan
Source§impl From<ValueWithSpan> for Value
impl From<ValueWithSpan> for Value
Source§fn from(value: ValueWithSpan) -> Self
fn from(value: ValueWithSpan) -> Self
Converts to this type from the input type.
Source§impl Hash for ValueWithSpan
impl Hash for ValueWithSpan
Source§impl Ord for ValueWithSpan
impl Ord for ValueWithSpan
Source§impl PartialEq for ValueWithSpan
impl PartialEq for ValueWithSpan
Source§impl PartialOrd for ValueWithSpan
impl PartialOrd for ValueWithSpan
Source§impl Serialize for ValueWithSpan
impl Serialize for ValueWithSpan
Source§impl Spanned for ValueWithSpan
impl Spanned for ValueWithSpan
Source§impl Visit for ValueWithSpan
impl Visit for ValueWithSpan
Source§impl VisitMut for ValueWithSpan
impl VisitMut for ValueWithSpan
fn visit<V: VisitorMut>(&mut self, visitor: &mut V) -> ControlFlow<V::Break>
impl Eq for ValueWithSpan
Auto Trait Implementations§
impl Freeze for ValueWithSpan
impl RefUnwindSafe for ValueWithSpan
impl Send for ValueWithSpan
impl Sync for ValueWithSpan
impl Unpin for ValueWithSpan
impl UnwindSafe for ValueWithSpan
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