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)
| 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 | /// |
nothing calls this directly
no test coverage detected