pub trait Segment: Sized {
// Required methods
fn remove(&mut self, args: ArgsType);
fn split(&mut self, pos: usize, args: ArgsType) -> Self;
fn modify(&mut self, new_flag: IdentType, args: ArgsType);
// Provided methods
fn shrink_to_left(&mut self, pos: usize, args: ArgsType) { ... }
fn shrink_to_right(&mut self, pos: usize, args: ArgsType) { ... }
fn split_and_remove_middle(
&mut self,
pos_left: usize,
pos_right: usize,
args: ArgsType,
) -> Self { ... }
fn modify_left(
&mut self,
pos: usize,
new_flag: IdentType,
args: ArgsType,
) -> Self { ... }
fn modify_right(
&mut self,
pos: usize,
new_flag: IdentType,
args: ArgsType,
) -> Self { ... }
fn modify_middle(
&mut self,
pos_left: usize,
pos_right: usize,
new_flag: IdentType,
args: ArgsType,
) -> (Self, Self) { ... }
}
Expand description
维护一段相同权限的地址区间的线段
Required Methods§
Provided Methods§
Sourcefn shrink_to_left(&mut self, pos: usize, args: ArgsType)
fn shrink_to_left(&mut self, pos: usize, args: ArgsType)
按 pos 拆分区间,只保留左半边
注意pos 参数为绝对位置而非相对位置
Sourcefn shrink_to_right(&mut self, pos: usize, args: ArgsType)
fn shrink_to_right(&mut self, pos: usize, args: ArgsType)
按 pos 拆分区间,只保留右半边
注意pos 参数为绝对位置而非相对位置
Sourcefn split_and_remove_middle(
&mut self,
pos_left: usize,
pos_right: usize,
args: ArgsType,
) -> Self
fn split_and_remove_middle( &mut self, pos_left: usize, pos_right: usize, args: ArgsType, ) -> Self
按 pos_left 和 pos_right 把区间拆成三段,默认不检查 pos_left <= pos_right。 然后 self 结构变成左半边区间,删除中间的区间,返回右半边区间
注意pos 参数为绝对位置而非相对位置
Sourcefn modify_left(
&mut self,
pos: usize,
new_flag: IdentType,
args: ArgsType,
) -> Self
fn modify_left( &mut self, pos: usize, new_flag: IdentType, args: ArgsType, ) -> Self
按 pos 拆分区间,并将左半边区间的属性修改为 new_flag。 self 结构变成左半边,返回右半边
注意pos 参数为绝对位置而非相对位置
Sourcefn modify_right(
&mut self,
pos: usize,
new_flag: IdentType,
args: ArgsType,
) -> Self
fn modify_right( &mut self, pos: usize, new_flag: IdentType, args: ArgsType, ) -> Self
按 pos 拆分区间,并将右半边区间的属性修改为 new_flag。 self 结构变成左半边,返回右半边
注意pos 参数为绝对位置而非相对位置
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.