ValueWithSpan in sqlparser::ast - Rust

Struct ValueWithSpan 

Source

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 Values

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();

A Value paired with its source Span location.

The wrapped Value.

The source Span covering the token(s) that produced the value.

Source§
Source

If the underlying literal is a string, regardless of quote style, returns the associated string value

§
§
§
§
§
§