Keep the \n in the doc comment as it is (don't replace it to newline)

This commit is contained in:
TheAwiteb 2023-09-10 10:07:31 +03:00
parent 4fe40f48b1
commit 9545075023
No known key found for this signature in database
GPG key ID: ABF818BD15DC2D34
2 changed files with 4 additions and 4 deletions

View file

@ -154,7 +154,7 @@ pub(crate) fn parse_doc_comment(attr: &Attribute) -> Option<String> {
if let syn::Meta::NameValue(syn::MetaNameValue { lit: syn::Lit::Str(s), .. }) = if let syn::Meta::NameValue(syn::MetaNameValue { lit: syn::Lit::Str(s), .. }) =
attr.parse_meta().ok()? attr.parse_meta().ok()?
{ {
return Some(s.value().trim().replace(r"\n", "\n")); return Some(s.value().trim().to_owned());
} }
} }
None None

View file

@ -250,7 +250,7 @@ fn description_with_doc_attr() {
enum DefaultCommands { enum DefaultCommands {
/// Start command /// Start command
Start, Start,
/// Help command\nwith new line /// Help command\nwithout replace the `\n`
Help, Help,
/// Foo command /// Foo command
/// with new line /// with new line
@ -259,8 +259,8 @@ fn description_with_doc_attr() {
assert_eq!( assert_eq!(
DefaultCommands::descriptions().to_string(), DefaultCommands::descriptions().to_string(),
"/start — Start command\n/help — Help command\nwith new line\n/foo — Foo command\nwith \ "/start — Start command\n/help — Help command\\nwithout replace the `\\n`\n/foo — Foo \
new line" command\nwith new line"
); );
} }