Quine

There are a couple of quines I wrote. Not the shortest or most code golfed implementations, but they are mine. They generally follow the same idea anyway.

Rust

Passes rustfmt and clippy::pedantic.

fn main() {
    println!("{Q}\nconst Q: &str = r{0}\"{Q}\"{0};", '#');
}
const Q: &str = r#"fn main() {
    println!("{Q}\nconst Q: &str = r{0}\"{Q}\"{0};", '#');
}"#;

The shortest implementation is fairly cool.

Zig

This one is fairly longwinded due to Zig's otherwise very nice multiline string literals syntax. Passes zig fmt.

pub fn main() !void {
    try o.print("{s}\nconst Q =\n", .{Q});
    var it = @import("std").mem.splitScalar(u8, Q, '\n');
    while (it.next()) |l| try o.print("    \\\\{s}\n", .{l});
    try o.writeAll(";\nconst o = @import(\"std\").io.getStdOut().writer();\n");
}
const Q =
    \\pub fn main() !void {
    \\    try o.print("{s}\nconst Q =\n", .{Q});
    \\    var it = @import("std").mem.splitScalar(u8, Q, '\n');
    \\    while (it.next()) |l| try o.print("    \\\\{s}\n", .{l});
    \\    try o.writeAll(";\nconst o = @import(\"std\").io.getStdOut().writer();\n");
    \\}
;
const o = @import("std").io.getStdOut().writer();

Swift

No main function but different order.

let Q = #"""
print("let Q = #\"\"\"\n\(Q)\n\"\"\"#\n\(Q)")
"""#
print("let Q = #\"\"\"\n\(Q)\n\"\"\"#\n\(Q)")