diff --git a/src/yycc/patch/format.hpp b/src/yycc/patch/format.hpp index c7d7b21..afea7a7 100644 --- a/src/yycc/patch/format.hpp +++ b/src/yycc/patch/format.hpp @@ -19,7 +19,6 @@ namespace yycc::patch::format { - // TODO: order all use of std::format redirect to this function. // TODO: all use of OP::printf should also switch to this function if possible. template diff --git a/src/yycc/rust/panic.cpp b/src/yycc/rust/panic.cpp index dbe158d..37c671f 100644 --- a/src/yycc/rust/panic.cpp +++ b/src/yycc/rust/panic.cpp @@ -18,7 +18,7 @@ namespace yycc::rust::panic { // It seems that STL providers are not ready for this feature. So I decide remove it entirely. // Once every STL probiders have ready for this, I will add it back. - void panic(const char* file, int line, const std::string_view& msg) { + void panic(const char* file, int line, const std::u8string_view& msg) { // Output message in stderr. auto& dst = std::cerr; diff --git a/src/yycc/rust/panic.hpp b/src/yycc/rust/panic.hpp index ef95b3e..25f18e1 100644 --- a/src/yycc/rust/panic.hpp +++ b/src/yycc/rust/panic.hpp @@ -1,4 +1,5 @@ #pragma once +#include "../patch/format.hpp" #include #include @@ -22,19 +23,15 @@ */ namespace yycc::rust::panic { - /** - * @brief Immediately crashes the entire program like Rust's \c panic! macro. - * @details The macro parameter is the additional message to display. - */ -#define RS_PANIC(msg) ::yycc::rust::panic::panic(__FILE__, __LINE__, (msg)) - /** * @brief Immediately crashes the entire program like Rust's \c panic! macro. * @details * The macro parameters are the message to format and its arguments, following \c std::format syntax. * This macro essentially calls \c std::format internally. + * However, this format function is specially modified that it can accept UTF8 format string and UTF8 string argument. + * More preciously, it is "format" in \c yycc::patch::format namespace. */ -#define RS_PANICF(msg, ...) RS_PANIC(std::format(msg __VA_OPT__(,) __VA_ARGS__)) +#define RS_PANIC(msg, ...) ::yycc::rust::panic::panic(__FILE__, __LINE__, ::yycc::patch::format::format(msg __VA_OPT__(, ) __VA_ARGS__)) /** * @brief Immediately crashes the entire program like Rust's \c panic! macro. @@ -45,6 +42,6 @@ namespace yycc::rust::panic { * @param[in] line Line number in source file where panic occurred. Usually filled by macros. * @param[in] msg Message to display during panic. */ - [[noreturn]] void panic(const char* file, int line, const std::string_view& msg); + [[noreturn]] void panic(const char* file, int line, const std::u8string_view& msg); } // namespace yycc::rust::panic