MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / new

Method new

src/sql-parser/src/ast/defs/name.rs:72–86  ·  view source on GitHub ↗

Create a new [`Ident`] with the given value, checking our invariants. # Examples ``` use mz_sql_parser::ast::Ident; let id = Ident::new("hello_world").unwrap(); assert_eq!(id.as_str(), "hello_world"); let too_long = "I am a very long identifier that is more than 255 bytes long which is the max length for idents.\ 😊😁😅😂😬🍻😮‍💨😮🗽🛰️🌈😊😁😅😂😬🍻😮‍💨😮🗽🛰️🌈😊😁😅😂😬🍻😮‍💨😮🗽🛰️🌈"; assert_eq!(too_long.len(), 258); le

(s: S)

Source from the content-addressed store, hash-verified

70 /// ```
71 ///
72 pub fn new<S>(s: S) -> Result<Self, IdentError>
73 where
74 S: TryInto<IdentString>,
75 <S as TryInto<IdentString>>::Error: fmt::Display,
76 {
77 let s = s
78 .try_into()
79 .map_err(|e| IdentError::TooLong(e.to_string()))?;
80
81 if &*s == "." || &*s == ".." {
82 return Err(IdentError::Invalid(s.into_inner()));
83 }
84
85 Ok(Ident(s.into_inner()))
86 }
87
88 /// Create a new [`Ident`] modifying the given value as necessary to meet our invariants.
89 ///

Callers

nothing calls this directly

Calls 4

IdentClass · 0.85
try_intoMethod · 0.45
to_stringMethod · 0.45
into_innerMethod · 0.45

Tested by

no test coverage detected