switch from unicode_xid to unicode_ident (#73)

This commit is contained in:
Adam Leventhal 2022-05-23 08:56:35 -07:00 committed by GitHub
parent 3bc3d5972b
commit 24fb7b9611
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

2
Cargo.lock generated
View File

@ -949,7 +949,7 @@ dependencies = [
"syn",
"thiserror",
"typify",
"unicode-xid",
"unicode-ident",
]
[[package]]

View File

@ -21,7 +21,7 @@ serde_json = "1.0"
syn = { version = "1.0", features = ["parsing"] }
thiserror = "1.0"
typify = "0.0.8"
unicode-xid = "0.2"
unicode-ident = "1.0.0"
[dev-dependencies]
dropshot = { git = "https://github.com/oxidecomputer/dropshot", default-features = false }

View File

@ -4,7 +4,7 @@ use indexmap::IndexMap;
use openapiv3::{
Components, Parameter, ReferenceOr, RequestBody, Response, Schema,
};
use unicode_xid::UnicodeXID;
use unicode_ident::{is_xid_continue, is_xid_start};
use crate::Result;
@ -82,13 +82,13 @@ pub(crate) fn sanitize(input: &str, case: Case) -> String {
_ => to_case(
&input
.replace("'", "")
.replace(|c: char| !c.is_xid_continue(), "-"),
.replace(|c: char| !is_xid_continue(c), "-"),
),
};
let out = match out.chars().next() {
None => to_case("x"),
Some(c) if c.is_xid_start() => out,
Some(c) if is_xid_start(c) => out,
Some(_) => format!("_{}", out),
};