Function unicode_bidi::get_base_direction
source · pub fn get_base_direction<'a, T: TextSource<'a> + ?Sized>(
text: &'a T
) -> Direction
Expand description
Get the base direction of the text provided according to the Unicode Bidirectional Algorithm.
See rules P2 and P3.
The base direction is derived from the first character in the string with bidi character type L, R, or AL. If the first such character has type L, Direction::Ltr is returned. If the first such character has type R or AL, Direction::Rtl is returned.
If the string does not contain any character of these types (outside of embedded isolate runs), then Direction::Mixed is returned (but should be considered as meaning “neutral” or “unknown”, not in fact mixed directions).
This is a lightweight function for use when only the base direction is needed and no further bidi processing of the text is needed.
If the text contains paragraph separators, this function considers only the first paragraph.