Skip to content

Inconsistent locale options for constructors #7261

@mihnita

Description

@mihnita

I would expect the code below to work:

use icu::locale::locale;

use icu::datetime::fieldsets::YMD;
use icu::datetime::DateTimeFormatter;

use icu::segmenter::WordSegmenter;

fn main() {
    let _formatter = DateTimeFormatter::try_new(
        locale!("en").into(),
        YMD::medium()
    );

    let _segmenter = WordSegmenter::try_new_auto(
        locale!("en").into()
    );
}

But it fails with

error[E0277]: the trait bound `WordBreakOptions<'_>: From<Locale>` is not satisfied
  --> src\main.rs:15:9
   |
15 |         locale!("en").into()
   |         ^^^^^^^^^^^^^ ---- required by a bound introduced by this call
   |         |
   |         the trait `From<Locale>` is not implemented for `WordBreakOptions<'_>`
   |
   = note: required for `Locale` to implement `Into<WordBreakOptions<'_>>`

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-metaComponent: Relating to ICU4X as a whole

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions