Remove strip_str_prefix() in favor of built-in strip_prefix()
MODIFY
binding-generator/src/comment.rs
binding-generator/src/comment.rs
@@ -26,7 +26,7 @@ pub fn strip_comment_markers(comment: &str) -> String {
if line_clean.starts_with(MULTILINE_PREFIX) {
singleline_delimited = false;
line = &line_clean[MULTILINE_PREFIX.len()..];
- if let Some(new_line) = line.strip_str_prefix(MULTILINE_CONT) {
+ if let Some(new_line) = line.strip_prefix(MULTILINE_CONT) {
line = new_line;
asterisk_indented = true;
} else {
@@ -37,7 +37,7 @@ pub fn strip_comment_markers(comment: &str) -> String {
singleline_delimited = true;
asterisk_indented = false;
}
- } else if let Some(line_clean) = line_clean.strip_str_prefix(MULTILINE_PREFIX) {
+ } else if let Some(line_clean) = line_clean.strip_prefix(MULTILINE_PREFIX) {
line = line_clean
.trim_start_matches(DETAIL)
.trim_start_matches(MULTILINE_CONT)
@@ -45,12 +45,12 @@ pub fn strip_comment_markers(comment: &str) -> String {
}
if singleline_delimited && line_clean.starts_with(SINGLELINE) {
line = &line_clean[SINGLELINE.len()..];
- if let Some(new_line) = line.strip_str_prefix(SINGLELINE_DETAIL) {
+ if let Some(new_line) = line.strip_prefix(SINGLELINE_DETAIL) {
line = new_line;
- } else if let Some(new_line) = line.strip_str_prefix(DETAIL) {
+ } else if let Some(new_line) = line.strip_prefix(DETAIL) {
line = new_line;
}
- if let Some(new_line) = line.strip_str_prefix(SINGLELINE_SIDE) {
+ if let Some(new_line) = line.strip_prefix(SINGLELINE_SIDE) {
line = new_line;
}
} else if asterisk_indented && i == 1 && !line_clean.starts_with(MULTILINE_CONT) {
@@ -87,7 +87,7 @@ pub fn strip_comment_markers(comment: &str) -> String {
for line in &mut lines {
if !singleline_delimited && asterisk_indented {
let line_trimmed = line.trim_start();
- if let Some(line_trimmed) = line_trimmed.strip_str_prefix(MULTILINE_CONT) {
+ if let Some(line_trimmed) = line_trimmed.strip_prefix(MULTILINE_CONT) {
*line = line_trimmed;
} else {
let trim_start = line.trim_start_idx().min(2);

MODIFY
binding-generator/src/func.rs
binding-generator/src/func.rs
@@ -123,7 +123,7 @@ impl<'tu> Func<'tu> {
const OPERATOR: &str = "operator";
match self.entity.get_kind() {
EntityKind::FunctionDecl => {
- if let Some(operator) = self.entity.cpp_localname().strip_str_prefix(OPERATOR) {
+ if let Some(operator) = self.entity.cpp_localname().strip_prefix(OPERATOR) {
let arg_count = self.entity.get_arguments().map_or(0, |v| v.len());
Kind::FunctionOperator(OperatorKind::new(operator.trim(), arg_count))
} else {
@@ -143,7 +143,7 @@ impl<'tu> Func<'tu> {
);
if self.entity.is_static_method() {
Kind::StaticMethod(class)
- } else if let Some(operator) = self.entity.cpp_localname().strip_str_prefix(OPERATOR) {
+ } else if let Some(operator) = self.entity.cpp_localname().strip_prefix(OPERATOR) {
let arg_count = self.entity.get_arguments().map_or(0, |v| v.len());
Kind::InstanceOperator(class, OperatorKind::new(operator.trim(), arg_count))
} else {

MODIFY
binding-generator/src/string_ext.rs
binding-generator/src/string_ext.rs
@@ -331,7 +331,6 @@ pub trait StrExt {
fn compile_interpolation(&self) -> CompiledInterpolation;
fn trim_start_idx(&self) -> usize;
fn trim_end_idx(&self) -> usize;
- fn strip_str_prefix(&self, prefix: &str) -> Option<&str>;
fn localname(&self) -> &str;
fn namespace(&self) -> &str;
}
@@ -438,14 +437,6 @@ impl StrExt for str {
.map_or(0, |(i, _)| i + 1)
}
- fn strip_str_prefix(&self, prefix: &str) -> Option<&str> {
- if self.starts_with(prefix) {
- Some(unsafe { self.get_unchecked(prefix.len()..) })
- } else {
- None
- }
- }
-
fn localname(&self) -> &str {
const SEP: &str = "::";
if let Some(idx) = self.rfind(SEP) {

MODIFY
binding-generator/src/writer/rust_native/class.rs
binding-generator/src/writer/rust_native/class.rs
@@ -152,7 +152,7 @@ fn gen_rust_class(c: &Class, opencv_version: &str) -> String {
let mut typ = type_ref.rust_full();
// hack for converting the references to array types in struct definitions
if type_ref.as_fixed_array().is_some() {
- if let Some(new_typ) = typ.strip_str_prefix("&mut ") {
+ if let Some(new_typ) = typ.strip_prefix("&mut ") {
typ = new_typ.to_string().into()
}
}

Remove strip_str_prefix() in favor of built-in strip_prefix()