mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-01 13:11:11 +00:00
Eliminate todo!()
s
This commit is contained in:
parent
5b01c048af
commit
7d25c1b54d
5 changed files with 15 additions and 15 deletions
|
@ -417,7 +417,7 @@ impl StyledStrings {
|
|||
///
|
||||
/// ```
|
||||
pub fn push_str(&mut self, s: &str) {
|
||||
if self.is_same_color(Color::Gray) {
|
||||
if self.color_is(Color::Gray) {
|
||||
self.texts.last_mut().unwrap().text.push_str(s);
|
||||
} else {
|
||||
self.texts.push(StyledString::new(s, None, None));
|
||||
|
@ -438,7 +438,7 @@ impl StyledStrings {
|
|||
/// println!("{}", texts);
|
||||
/// ```
|
||||
pub fn push_str_with_color<'a, S: Into<Cow<'a, str>>>(&mut self, s: S, color: Color) {
|
||||
if self.is_same_color(color) {
|
||||
if self.color_is(color) {
|
||||
let text = s.into();
|
||||
self.texts.last_mut().unwrap().text.push_str(&text);
|
||||
} else {
|
||||
|
@ -465,7 +465,7 @@ impl StyledStrings {
|
|||
color: Color,
|
||||
attr: Attribute,
|
||||
) {
|
||||
if self.is_same_color(color) && self.is_same_attribute(attr) {
|
||||
if self.color_is(color) && self.attr_is(attr) {
|
||||
let text = s.into();
|
||||
self.texts.last_mut().unwrap().text.push_str(&text);
|
||||
} else {
|
||||
|
@ -482,14 +482,14 @@ impl StyledStrings {
|
|||
self.texts.iter().all(|s| s.is_empty())
|
||||
}
|
||||
|
||||
fn is_same_color(&self, color: Color) -> bool {
|
||||
fn color_is(&self, color: Color) -> bool {
|
||||
if let Some(text) = self.texts.last() {
|
||||
return text.color == Some(color);
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn is_same_attribute(&self, attr: Attribute) -> bool {
|
||||
fn attr_is(&self, attr: Attribute) -> bool {
|
||||
if let Some(text) = self.texts.last() {
|
||||
if let Some(text_attr) = text.attribute {
|
||||
return text_attr == attr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue