// Note the flipped order of the words `Collator` and `Resolved`, because // in FFI `Collator` is part of the `Collator` prefix, but in Rust, // `ResolvedCollatorOptions` makes more sense as English. #[diplomat::rust_link(icu::collator::options::ResolvedCollatorOptions, Struct)] #[diplomat::out] #[diplomat::attr(supports = non_exhaustive_structs, rename = "CollatorResolvedOptions")] pubstruct CollatorResolvedOptionsV1 { pub strength: CollatorStrength, pub alternate_handling: CollatorAlternateHandling, pub case_first: CollatorCaseFirst, pub max_variable: CollatorMaxVariable, pub case_level: CollatorCaseLevel, pub numeric: CollatorNumericOrdering,
}
/// Construct a new Collator instance using a particular data source. #[diplomat::rust_link(icu::collator::Collator::try_new, FnInStruct)] #[diplomat::rust_link(icu::collator::CollatorBorrowed::try_new, FnInStruct, hidden)] #[diplomat::rust_link(icu::collator::CollatorPreferences, Struct, hidden)] #[diplomat::attr(all(supports = fallible_constructors, supports = named_constructors), named_constructor = "with_provider")] #[diplomat::attr(supports = non_exhaustive_structs, rename = "create_with_provider")] #[cfg(feature = "buffer_provider")] pubfn create_v1_with_provider(
provider: &DataProvider,
locale: &Locale,
options: CollatorOptionsV1,
) -> Result<Box<Collator>, DataError> { let options = options.into();
Ok(Box::new(Collator(
icu_collator::Collator::try_new_with_buffer_provider(
provider.get()?,
(&locale.0).into(),
options,
)?,
)))
} /// Compare two strings. /// /// Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according /// to the WHATWG Encoding Standard. #[diplomat::rust_link(icu::collator::CollatorBorrowed::compare_utf8, FnInStruct)] #[diplomat::rust_link(icu::collator::CollatorBorrowed::compare, FnInStruct, hidden)] #[diplomat::attr(not(supports = utf8_strings), disable)] #[diplomat::attr(supports = utf8_strings, rename = "compare")] pubfn compare_utf8(&self, left: &DiplomatStr, right: &DiplomatStr) -> core::cmp::Ordering { self.0.as_borrowed().compare_utf8(left, right)
}
/// Compare two strings. /// /// Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according /// to the WHATWG Encoding Standard. #[diplomat::rust_link(icu::collator::CollatorBorrowed::compare_utf16, FnInStruct)] #[diplomat::attr(not(supports = utf8_strings), rename = "compare")] #[diplomat::attr(supports = utf8_strings, rename = "compare16")] pubfn compare_utf16(
&self,
left: &DiplomatStr16,
right: &DiplomatStr16,
) -> core::cmp::Ordering { self.0.as_borrowed().compare_utf16(left, right)
}
/// The resolved options showing how the default options, the requested options, /// and the options from locale data were combined. None of the struct fields /// will have `Auto` as the value. #[diplomat::rust_link(icu::collator::CollatorBorrowed::resolved_options, FnInStruct)] #[diplomat::attr(auto, getter)] #[diplomat::attr(supports = non_exhaustive_structs, rename = "resolved_options")] pubfn resolved_options_v1(&self) -> CollatorResolvedOptionsV1 { self.0.as_borrowed().resolved_options().into()
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.