pub fn insert(&mut self, mut pos: usize, contents: &str) {
        if contents.is_empty() { return; }
        pos = std::cmp::min(pos, self.len_chars());

        let mut cursor = self.cursor_at_char(pos, true);
        unsafe { self.insert_at_cursor(&mut cursor, contents); }

        debug_assert_eq!(cursor.global_char_pos(self.head.height), pos + count_chars(contents));
        // dbg!(&cursor.0[..self.head.height as usize]);
    }
/// Insert new content into the rope. The content is inserted at the specified unicode character
/// offset, which is different from a byte offset for non-ASCII characters.
///
/// # Example
///
/// ```
/// # use jumprope::*;
/// let mut rope = JumpRope::from("--");
/// rope.insert(1, "hi there");
/// assert_eq!(rope.to_string(), "-hi there-");
/// ```
///
/// If the position names a location past the end of the rope, it is truncated.
Insert new content into the rope. The content is inserted at the specified unicode character
offset, which is different from a byte offset for non-ASCII characters.
Insert new content into the rope . The content is inserted at the specified unicode character offset which is different from a byte offset for non - ASCII characters .
pub fn insert(&mut self, mut pos: usize, contents: &str) {
        if contents.is_empty() { return; }
        pos = std::cmp::min(pos, self.len_chars());
        let mut cursor = self.cursor_at_char(pos, true);
        unsafe { self.insert_at_cursor(&mut cursor, contents); }
        debug_assert_eq!(cursor.global_char_pos(self.head.height), pos + count_chars(contents));
        // dbg!(&cursor.0[..self.head.height as usize]);
    }
pub fn insert ( & mut self , mut pos : usize , contents : & str ) { if contents . is_empty ( ) { return ; } pos = std :: cmp :: min ( pos , self . len_chars ( ) ) ; let mut cursor = self . cursor_at_char ( pos , true ) ; unsafe { self . insert_at_cursor ( & mut cursor , contents ) ; } debug_assert_eq ! ( cursor global_char_pos ( self head height ) pos count_chars ( contents ) ) ; // dbg!(&cursor.0[..self.head.height as usize]); }
Insert new content into the rope.
Insert new content into the rope .
&mut self
pos
usize
contents
&str
example
None
use jumprope::*;
let mut rope = JumpRope::from("--");
rope.insert(1, "hi there");
assert_eq!(rope.to_string(), "-hi there-");
```

If the position names a location past the end of the rope, it is truncated.
let mut rope = JumpRope :: from ( " -- " ) ; rope . insert ( 1 " hi there " ) ; assert_eq! ( rope . to_string () " - hi there - " ) ; ` ` ` If the position names a location past the end of the rope it is truncated .