diff --git a/lib/cldr_collation/nif.ex b/lib/cldr_collation/nif.ex deleted file mode 100644 index 332695a..0000000 --- a/lib/cldr_collation/nif.ex +++ /dev/null @@ -1,6 +0,0 @@ -defmodule Cldr.Collation.Nif do - use Rustler, - otp_app: :ex_cldr_collation - - def sort(_locale, _list, _opts), do: :erlang.nif_error(:nif_not_loaded) -end diff --git a/mix.exs b/mix.exs index 2b14d0c..e65ebcd 100644 --- a/mix.exs +++ b/mix.exs @@ -41,7 +41,6 @@ defmodule CldrCollation.MixProject do defp deps do [ - {:rustler, "~> 0.28.0"}, {:elixir_make, "~> 0.4", runtime: false}, {:ex_doc, "~> 0.19", only: :dev, runtime: false, optional: true}, {:dialyxir, "~> 1.4", only: [:dev], runtime: false} diff --git a/native/ex_cldr_collation/.cargo/config.toml b/native/ex_cldr_collation/.cargo/config.toml deleted file mode 100644 index 20f03f3..0000000 --- a/native/ex_cldr_collation/.cargo/config.toml +++ /dev/null @@ -1,5 +0,0 @@ -[target.'cfg(target_os = "macos")'] -rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", -] diff --git a/native/ex_cldr_collation/.gitignore b/native/ex_cldr_collation/.gitignore deleted file mode 100644 index ea8c4bf..0000000 --- a/native/ex_cldr_collation/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/native/ex_cldr_collation/Cargo.lock b/native/ex_cldr_collation/Cargo.lock deleted file mode 100644 index 80daead..0000000 --- a/native/ex_cldr_collation/Cargo.lock +++ /dev/null @@ -1,583 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aho-corasick" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" -dependencies = [ - "memchr", -] - -[[package]] -name = "displaydoc" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.16", -] - -[[package]] -name = "either" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" - -[[package]] -name = "ex_cldr_collation" -version = "0.1.0" -dependencies = [ - "icu_collator", - "icu_locid", - "icu_testdata", - "rustler", -] - -[[package]] -name = "fixed_decimal" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c9eab2dd2aadbc55056ed228ccc4be42d07cd61aee72d48768f8ac2e4ab7d54" -dependencies = [ - "displaydoc", - "smallvec", - "writeable", -] - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "icu_calendar" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee1e8c25ed44743d03e2d58ca1c0226786dc1aac1f9cb27485e2da2de5e0918" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_provider", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_collator" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "088882827079b243dc01883f92290dd3952b656faddc7a2972e6d3ab47e1fc7a" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_locid", - "icu_normalizer", - "icu_properties", - "icu_provider", - "smallvec", - "utf16_iter", - "utf8_iter", - "zerovec", -] - -[[package]] -name = "icu_collections" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8302d8dfd6044d3ddb3f807a5ef3d7bbca9a574959c6d6e4dc39aa7012d0d5" -dependencies = [ - "displaydoc", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_datetime" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72d61014bb8604505baa84ed522aa039951bd81177828d165e80ea8a0543c8a7" -dependencies = [ - "displaydoc", - "either", - "fixed_decimal", - "icu_calendar", - "icu_decimal", - "icu_locid", - "icu_plurals", - "icu_provider", - "icu_timezone", - "smallvec", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_decimal" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "839d40602460578482205f1def416a6442cf29a24dc366aa8cf8d9f95a53c9d2" -dependencies = [ - "displaydoc", - "fixed_decimal", - "icu_locid", - "icu_provider", - "writeable", -] - -[[package]] -name = "icu_list" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd7ba7442d9235b689d4fdce17c452ea229934980fd81ba50cc28275752c9f90" -dependencies = [ - "displaydoc", - "icu_provider", - "regex-automata", - "writeable", -] - -[[package]] -name = "icu_locid" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3003f85dccfc0e238ff567693248c59153a46f4e6125ba4020b973cef4d1d335" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_locid_transform" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd89f392982141a878a9321c9298cce46d14e1c17efc5f428dbfd96b443e57d0" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_normalizer" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "652869735c9fb9f5a64ba180ee16f2c848390469c116deef517ecc53f4343598" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_properties", - "icu_provider", - "smallvec", - "utf16_iter", - "utf8_iter", - "write16", - "zerovec", -] - -[[package]] -name = "icu_plurals" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18fbe19656b3cbae9a40a27b0303f06b2b51165e3b06d596dfdff8f06bfce9a" -dependencies = [ - "displaydoc", - "fixed_decimal", - "icu_locid", - "icu_provider", - "zerovec", -] - -[[package]] -name = "icu_properties" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce0e1aa26851f16c9e04412a5911c86b7f8768dac8f8d4c5f1c568a7e5d7a434" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_provider" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dc312a7b6148f7dfe098047ae2494d12d4034f48ade58d4f353000db376e305" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_provider_macros", - "stable_deref_trait", - "writeable", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_provider_adapters" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4ae1e2bd0c41728b77e7c46e9afdec5e2127d1eedacc684724667d50c126bd3" -dependencies = [ - "icu_locid", - "icu_provider", - "tinystr", - "yoke", - "zerovec", -] - -[[package]] -name = "icu_provider_macros" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b728b9421e93eff1d9f8681101b78fa745e0748c95c655c83f337044a7e10" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "icu_segmenter" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3300a7b6bf187be98a57264ad094f11f2e062c2e8263132af010ff522ee5495" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_locid", - "icu_provider", - "utf8_iter", - "zerovec", -] - -[[package]] -name = "icu_testdata" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c91edb7412e04e7f71ec935d0b88954c6d414ad21ede85ab80d512e27540c9" -dependencies = [ - "icu_calendar", - "icu_collator", - "icu_collections", - "icu_datetime", - "icu_decimal", - "icu_list", - "icu_locid", - "icu_locid_transform", - "icu_normalizer", - "icu_plurals", - "icu_properties", - "icu_provider", - "icu_provider_adapters", - "icu_segmenter", - "icu_timezone", - "zerovec", -] - -[[package]] -name = "icu_timezone" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e22da75a450de2d54161838efa9e1a1f5baa7bc1fffdb015f260e0992b01977" -dependencies = [ - "displaydoc", - "icu_calendar", - "icu_locid", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "litemap" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a04a5b2b6f54acba899926491d0a6c59d98012938ca2ab5befb281c034e8f94" - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "proc-macro2" -version = "1.0.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa1fb82fc0c281dd9671101b66b771ebbe1eaf967b96ac8740dcba4b70005ca8" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "regex" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9368763f5a9b804326f3af749e16f9abf378d227bcdee7634b13d8f17793782" -dependencies = [ - "memchr", -] - -[[package]] -name = "regex-syntax" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" - -[[package]] -name = "rustler" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d7a2f98cb272ae0548e434bb3afde626012084cbebef84542bc7afed868bd6f" -dependencies = [ - "lazy_static", - "rustler_codegen", - "rustler_sys", -] - -[[package]] -name = "rustler_codegen" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ae37fb154683a1ff13e95dfd16c15043d6aee9853ea650ca34a45bd94e319a5" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 2.0.16", -] - -[[package]] -name = "rustler_sys" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ff26a42e62d538f82913dd34f60105ecfdffbdb25abdc3c3580b0c622285332" -dependencies = [ - "regex", - "unreachable", -] - -[[package]] -name = "serde" -version = "1.0.163" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" - -[[package]] -name = "smallvec" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - -[[package]] -name = "tinystr" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ac3f5b6856e931e15e07b478e98c8045239829a65f9156d4fa7e7788197a5ef" -dependencies = [ - "displaydoc", - "zerovec", -] - -[[package]] -name = "unicode-ident" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" - -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - -[[package]] -name = "unreachable" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" -dependencies = [ - "void", -] - -[[package]] -name = "utf16_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52df8b7fb78e7910d776fccf2e42ceaf3604d55e8e7eb2dbd183cb1441d8a692" - -[[package]] -name = "utf8_iter" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a8922555b9500e3d865caed19330172cd67cbf82203f1a3311d8c305cc9f33" - -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - -[[package]] -name = "write16" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" - -[[package]] -name = "writeable" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60e49e42bdb1d5dc76f4cd78102f8f0714d32edfa3efb82286eb0f0b1fc0da0f" - -[[package]] -name = "yoke" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1848075a23a28f9773498ee9a0f2cf58fcbad4f8c0ccf84a210ab33c6ae495de" -dependencies = [ - "serde", - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af46c169923ed7516eef0aa32b56d2651b229f57458ebe46b49ddd6efef5b7a2" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "zerofrom" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df54d76c3251de27615dfcce21e636c172dafb2549cd7fd93e21c66f6ca6bea2" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4eae7c1f7d4b8eafce526bc0771449ddc2f250881ae31c50d22c032b5a1c499" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "zerovec" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "198f54134cd865f437820aa3b43d0ad518af4e68ee161b444cdd15d8e567c8ea" -dependencies = [ - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "486558732d5dde10d0f8cb2936507c1bb21bc539d924c949baf5f36a58e51bac" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] diff --git a/native/ex_cldr_collation/Cargo.toml b/native/ex_cldr_collation/Cargo.toml deleted file mode 100644 index 06f3c3b..0000000 --- a/native/ex_cldr_collation/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "ex_cldr_collation" -version = "0.1.0" -edition = "2021" - -[lib] -name = "ex_cldr_collation" -path = "src/lib.rs" -crate-type = ["cdylib"] - -[dependencies] -icu_collator = "1.2.0" -icu_locid = "1.2.0" -icu_testdata = "1.2.0" -rustler = "0.28.0" diff --git a/native/ex_cldr_collation/src/collator_opts.rs b/native/ex_cldr_collation/src/collator_opts.rs deleted file mode 100644 index fde6017..0000000 --- a/native/ex_cldr_collation/src/collator_opts.rs +++ /dev/null @@ -1,152 +0,0 @@ -/// Due to Rust's orphan rule, we can't implement NifMap directly on icu_collator::CollatorOptions. -/// Furthermore, icu_collator::CollatorOptions is marked #[non_exhaustive], so we can't rely -/// on its fields being stable. -/// Thus we need to create our own version of CollatorOptions that we can use in our NIF API, and can be easily converted to icu_collator::ComparisonOptions. -/// This also allows us the flexibily to adjust the NIF API if we so choose, while still being compatible with icu_collator. - -use rustler::{NifMap, NifUnitEnum}; - -#[derive(NifUnitEnum)] -pub enum Strength { - Primary, - Secondary, - Tertiary, - Quaternary, - Identical, -} - -impl From for icu_collator::Strength { - fn from(opts: Strength) -> Self { - match opts { - Strength::Primary => icu_collator::Strength::Primary, - Strength::Secondary => icu_collator::Strength::Secondary, - Strength::Tertiary => icu_collator::Strength::Tertiary, - Strength::Quaternary => icu_collator::Strength::Quaternary, - Strength::Identical => icu_collator::Strength::Identical, - } - } -} - -#[derive(NifUnitEnum)] -pub enum AlternateHandling { - NonIgnorable, - Shifted, -} - -impl From for icu_collator::AlternateHandling { - fn from(opts: AlternateHandling) -> Self { - match opts { - AlternateHandling::NonIgnorable => icu_collator::AlternateHandling::NonIgnorable, - AlternateHandling::Shifted => icu_collator::AlternateHandling::Shifted, - } - } -} - -#[derive(NifUnitEnum)] -pub enum CaseFirst { - Off, - LowerFirst, - UpperFirst, -} - -impl From for icu_collator::CaseFirst { - fn from(opts: CaseFirst) -> Self { - match opts { - CaseFirst::Off => icu_collator::CaseFirst::Off, - CaseFirst::LowerFirst => icu_collator::CaseFirst::LowerFirst, - CaseFirst::UpperFirst => icu_collator::CaseFirst::UpperFirst, - } - } -} - -#[derive(NifUnitEnum)] -pub enum MaxVariable { - Space, - Punctuation, - Symbol, - Currency, -} - -impl From for icu_collator::MaxVariable { - fn from(opts: MaxVariable) -> Self { - match opts { - MaxVariable::Space => icu_collator::MaxVariable::Space, - MaxVariable::Punctuation => icu_collator::MaxVariable::Punctuation, - MaxVariable::Symbol => icu_collator::MaxVariable::Symbol, - MaxVariable::Currency => icu_collator::MaxVariable::Currency, - } - } -} - -#[derive(NifUnitEnum)] -pub enum CaseLevel { - Off, - On, -} - -impl From for icu_collator::CaseLevel { - fn from(opts: CaseLevel) -> Self { - match opts { - CaseLevel::Off => icu_collator::CaseLevel::Off, - CaseLevel::On => icu_collator::CaseLevel::On, - } - } -} - -#[derive(NifUnitEnum)] -pub enum Numeric { - Off, - On, -} - -impl From for icu_collator::Numeric { - fn from(opts: Numeric) -> Self { - match opts { - Numeric::Off => icu_collator::Numeric::Off, - Numeric::On => icu_collator::Numeric::On, - } - } -} - -#[derive(NifUnitEnum)] -pub enum BackwardSecondLevel { - Off, - On, -} - -impl From for icu_collator::BackwardSecondLevel { - fn from(opts: BackwardSecondLevel) -> Self { - match opts { - BackwardSecondLevel::Off => icu_collator::BackwardSecondLevel::Off, - BackwardSecondLevel::On => icu_collator::BackwardSecondLevel::On, - } - } -} - -#[derive(NifMap)] -pub struct CollatorOptions { - strength: Option, - alternate_handling: Option, - case_first: Option, - max_variable: Option, - case_level: Option, - numeric: Option, - backward_second_level: Option, -} - -impl From for icu_collator::CollatorOptions { - fn from(opts: CollatorOptions) -> Self { - let mut collator_options = icu_collator::CollatorOptions::new(); - - collator_options.strength = opts.strength.map(|s| s.into()); - collator_options.alternate_handling = opts.alternate_handling.map(|a| a.into()); - collator_options.case_first = opts.case_first.map(|c| c.into()); - collator_options.max_variable = opts.max_variable.map(|m| m.into()); - collator_options.case_level = opts.case_level.map(|c| c.into()); - collator_options.numeric = opts.numeric.map(|n| n.into()); - collator_options.backward_second_level = opts.backward_second_level.map(|b| b.into()); - - collator_options - } -} - diff --git a/native/ex_cldr_collation/src/lib.rs b/native/ex_cldr_collation/src/lib.rs deleted file mode 100644 index 023348b..0000000 --- a/native/ex_cldr_collation/src/lib.rs +++ /dev/null @@ -1,23 +0,0 @@ -mod collator_opts; - -use icu_collator::*; -use icu_locid::Locale; -use collator_opts::CollatorOptions; -use rustler::NifResult; - -#[rustler::nif] -fn sort<'a>( - locale_tag: &str, - list: Vec<&'a str>, - opts: CollatorOptions, -) -> NifResult> { - let locale: Locale = locale_tag.parse().map_err(|_| rustler::Error::BadArg)?; - let collator = - Collator::try_new_unstable(&icu_testdata::unstable(), &locale.into(), opts.into()).unwrap(); - - let mut list = list; - list.sort_by(|first, second| collator.compare(first, second)); - Ok(list) -} - -rustler::init!("Elixir.Cldr.Collation.Nif", [sort]);