pub struct IfmtInput {
pub source: LitStr,
pub segments: Vec<Segment>,
}
Expand description
A hot-reloadable formatted string, boolean, number or other literal
This wraps LitStr with some extra goodies like inline expressions and hot-reloading. Originally this was intended to provide named inline string interpolation but eventually Rust actually shipped this!
Fields§
§source: LitStr
§segments: Vec<Segment>
Implementations§
Source§impl IfmtInput
impl IfmtInput
pub fn new(span: Span) -> Self
pub fn new_litstr(source: LitStr) -> Result<Self>
pub fn span(&self) -> Span
pub fn push_raw_str(&mut self, other: String)
pub fn push_ifmt(&mut self, other: IfmtInput)
pub fn push_expr(&mut self, expr: Expr)
pub fn is_static(&self) -> bool
pub fn to_static(&self) -> Option<String>
pub fn dynamic_segments(&self) -> Vec<&FormattedSegment>
pub fn dynamic_seg_frequency_map(&self) -> HashMap<&FormattedSegment, usize>
Sourcepub fn to_string_with_quotes(&self) -> String
pub fn to_string_with_quotes(&self) -> String
print the original source string - this handles escapes and stuff for us
Trait Implementations§
Source§impl From<IfmtInput> for HotReloadFormattedSegment
impl From<IfmtInput> for HotReloadFormattedSegment
Source§impl ToTokens for IfmtInput
impl ToTokens for IfmtInput
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
impl Eq for IfmtInput
impl StructuralPartialEq for IfmtInput
Auto Trait Implementations§
impl Freeze for IfmtInput
impl RefUnwindSafe for IfmtInput
impl !Send for IfmtInput
impl !Sync for IfmtInput
impl Unpin for IfmtInput
impl UnwindSafe for IfmtInput
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere
T: Spanned + ?Sized,
Source§fn span(&self) -> Span
fn span(&self) -> Span
Returns a
Span
covering the complete contents of this syntax tree
node, or Span::call_site()
if this node is empty.