Skip to main content

TextLaws

Trait TextLaws 

Source
pub trait TextLaws<This>{
    // Required methods
    fn text_editor_laws(&mut self) -> Result<()>;
    fn check_law_editor(&self, text: &str, cursor: usize) -> Result<()>;
}
Expand description

Authors the text-editing laws.

Required Methods§

Source

fn text_editor_laws(&mut self) -> Result<()>

Checks that editing moves by Unicode scalar and never splits one.

The laws checked are:

  1. the cursor moves by whole scalars in both directions;
  2. insertion advances past exactly the inserted bytes;
  3. deleting before and at the cursor removes one whole scalar;
  4. every observed cursor rests on a UTF-8 boundary.
§Errors

Returns the first violated law.

Source

fn check_law_editor(&self, text: &str, cursor: usize) -> Result<()>

Checks the observed text and cursor against the meaning one edit denotes.

§Errors

Returns the violated law.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<This> TextLaws<This> for This

Authors the text-editing laws.