pub trait TextBuffer {
type Pos: Clone + Ord;
// Required methods
fn start_pos(&self) -> Self::Pos;
fn end_pos(&self) -> Self::Pos;
fn clamp_pos(&self, pos: Self::Pos) -> Self::Pos;
fn prev_boundary(&self, pos: Self::Pos) -> Self::Pos;
fn next_boundary(&self, pos: Self::Pos) -> Self::Pos;
fn text_between(&self, start: Self::Pos, end: Self::Pos) -> String;
fn replace(
&mut self,
start: Self::Pos,
end: Self::Pos,
text: &str,
) -> TextEdit<Self::Pos>;
}Expand description
文本缓冲区契约。
Pos 可以是字节偏移(String)或 { line, col }(行式文档)。
所有位置参数在算法内都先经 clamp_pos,实现方必须保证返回值落在合法边界上。
Required Associated Types§
Required Methods§
fn start_pos(&self) -> Self::Pos
fn end_pos(&self) -> Self::Pos
fn clamp_pos(&self, pos: Self::Pos) -> Self::Pos
fn prev_boundary(&self, pos: Self::Pos) -> Self::Pos
fn next_boundary(&self, pos: Self::Pos) -> Self::Pos
fn text_between(&self, start: Self::Pos, end: Self::Pos) -> String
fn replace( &mut self, start: Self::Pos, end: Self::Pos, text: &str, ) -> TextEdit<Self::Pos>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".