exercism/zig/reverse-string/reverse_string.zig

9 lines
205 B
Zig
Raw Normal View History

2024-09-20 17:07:22 -04:00
const std = @import("std");
/// Writes a reversed copy of `s` to `buffer`.
pub fn reverse(buffer: []u8, s: []const u8) []u8 {
@memcpy(buffer, s);
std.mem.reverse(u8, buffer);
return buffer;
}