Move the given string into `Self` if its length does not exceed `N`, or truncate it to the appropriate length. In case of truncation, the resulting string may be shorter than `N` if `N` falls on a character boundary.
(s: String)
| 47 | /// In case of truncation, the resulting string may be shorter than `N` if |
| 48 | /// `N` falls on a character boundary. |
| 49 | pub fn from_string_truncate(s: String) -> Self { |
| 50 | if s.len() <= N { |
| 51 | Self { inner: s } |
| 52 | } else { |
| 53 | let mut s = s; |
| 54 | while s.len() > N { |
| 55 | s.pop().unwrap(); |
| 56 | } |
| 57 | Self { inner: s } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | /// Discard the `Varchar` wrapper. |
| 62 | pub fn into_inner(self) -> String { |