Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions cpp2rust/converter/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,8 +1153,8 @@ bool Converter::GetFmtArg(clang::Expr *arg, std::string &fmt,
} else if (arg_str.contains("Setw")) {
fmt_width = ToString(arg);
// Delete leading and trailing whitespaces
fmt_width.erase(0, fmt_width.find_first_not_of(" "));
fmt_width.erase(fmt_width.find_last_not_of(" ") + 1);
fmt_width.erase(0, fmt_width.find_first_not_of(' '));
fmt_width.erase(fmt_width.find_last_not_of(' ') + 1);
} else if (!arg->getType()->isCharType() &&
Mapper::Map(arg->getType()) != "Vec<u8>") {
fmt += ("{:" + fmt_width + fmt_trait + "}");
Expand Down Expand Up @@ -2962,11 +2962,10 @@ void Converter::ConvertCXXMethodDecls(const clang::CXXRecordDecl *decl,
StrCat(token::kCloseCurlyBracket);
}

void Converter::ConvertOrdAndPartialOrdTraitsBase(std::string first_branch,
std::string second_branch,
std::string first_return,
std::string second_return,
std::string record_name) {
void Converter::ConvertOrdAndPartialOrdTraitsBase(
std::string_view first_branch, std::string_view second_branch,
std::string_view first_return, std::string_view second_return,
std::string_view record_name) {
StrCat(keyword::kImpl, "Ord for ", record_name, "{");
StrCat("fn cmp(&self, other: &Self) -> std::cmp::Ordering {");
StrCat(std::format("{} {{", keyword_unsafe_));
Expand Down
12 changes: 6 additions & 6 deletions cpp2rust/converter/converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
#define StrCat(...) _StrCat(__FUNCTION__, __LINE__, __VA_ARGS__)

template <typename... Ts>
inline void _StrCat(const char *func, int line, Ts... vals) {
inline void _StrCat(const char *func, int line, const Ts &...vals) {
llvm::errs() << '[' << func << ':' << line << "] ";
((llvm::errs() << vals << '\n', *rs_code_ += vals, *rs_code_ += ' '), ...);
}
Expand Down Expand Up @@ -389,11 +389,11 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
virtual void ConvertOrdAndPartialOrdTraits(const clang::CXXRecordDecl *decl,
const clang::FunctionDecl *op);

void ConvertOrdAndPartialOrdTraitsBase(std::string first_branch,
std::string second_branch,
std::string first_return,
std::string second_return,
std::string record_name);
void ConvertOrdAndPartialOrdTraitsBase(std::string_view first_branch,
std::string_view second_branch,
std::string_view first_return,
std::string_view second_return,
std::string_view record_name);

virtual void AddCloneTrait(const clang::CXXRecordDecl *decl);

Expand Down
Loading