MCPcopy Create free account
hub / github.com/davidblewett/rure-python / class

Function class

regex/regex-syntax/src/unicode.rs:211–276  ·  view source on GitHub ↗

Looks up a Unicode class given a query. If one doesn't exist, then `None` is returned.

(query: ClassQuery<'a>)

Source from the content-addressed store, hash-verified

209/// Looks up a Unicode class given a query. If one doesn't exist, then
210/// `None` is returned.
211pub fn class<'a>(query: ClassQuery<'a>) -> Result<hir::ClassUnicode> {
212 use self::CanonicalClassQuery::*;
213
214 match query.canonicalize()? {
215 Binary(name) => {
216 property_set(property_bool::BY_NAME, name)
217 .map(hir_class)
218 .ok_or(Error::PropertyNotFound)
219 }
220 GeneralCategory("Any") => {
221 Ok(hir_class(&[('\0', '\u{10FFFF}')]))
222 }
223 GeneralCategory("Assigned") => {
224 let mut cls =
225 property_set(general_category::BY_NAME, "Unassigned")
226 .map(hir_class)
227 .ok_or(Error::PropertyNotFound)?;
228 cls.negate();
229 Ok(cls)
230 }
231 GeneralCategory("ASCII") => {
232 Ok(hir_class(&[('\0', '\x7F')]))
233 }
234 GeneralCategory(name) => {
235 property_set(general_category::BY_NAME, name)
236 .map(hir_class)
237 .ok_or(Error::PropertyValueNotFound)
238 }
239 Script(name) => {
240 property_set(script::BY_NAME, name)
241 .map(hir_class)
242 .ok_or(Error::PropertyValueNotFound)
243 }
244 ByValue { property_name: "Age", property_value } => {
245 let mut class = hir::ClassUnicode::empty();
246 for set in ages(property_value)? {
247 class.union(&hir_class(set));
248 }
249 Ok(class)
250 }
251 ByValue { property_name: "Script_Extensions", property_value } => {
252 property_set(script_extension::BY_NAME, property_value)
253 .map(hir_class)
254 .ok_or(Error::PropertyValueNotFound)
255 }
256 ByValue { property_name: "Grapheme_Cluster_Break", property_value } => {
257 property_set(grapheme_cluster_break::BY_NAME, property_value)
258 .map(hir_class)
259 .ok_or(Error::PropertyValueNotFound)
260 }
261 ByValue { property_name: "Sentence_Break", property_value } => {
262 property_set(sentence_break::BY_NAME, property_value)
263 .map(hir_class)
264 .ok_or(Error::PropertyValueNotFound)
265 }
266 ByValue { property_name: "Word_Break", property_value } => {
267 property_set(word_break::BY_NAME, property_value)
268 .map(hir_class)

Callers 15

dotMethod · 0.85
anyMethod · 0.85
visit_postMethod · 0.85
hir_unicode_classMethod · 0.85
hir_uclass_queryFunction · 0.85
hir_uclass_perl_wordFunction · 0.85
hir_uclassFunction · 0.85
hir_bclassFunction · 0.85
hir_bclass_from_charFunction · 0.85
hir_case_foldFunction · 0.85

Calls 8

property_setFunction · 0.85
hir_classFunction · 0.85
agesFunction · 0.85
mapMethod · 0.80
emptyFunction · 0.50
canonicalizeMethod · 0.45
negateMethod · 0.45
unionMethod · 0.45

Tested by

no test coverage detected