Skip to content

Instantly share code, notes, and snippets.

@mikdusan
Last active December 19, 2022 17:42
Show Gist options
  • Save mikdusan/637cf6b1b134d2a291ab253492e38bdf to your computer and use it in GitHub Desktop.
Save mikdusan/637cf6b1b134d2a291ab253492e38bdf to your computer and use it in GitHub Desktop.
pub fn main() void {
const user_config_dir = "/tmp/foo";
// 1. swap out the `*c` notation: `[*c]u8` -> `[*:0]u8`
// 2. add const to indicate these aren't mutable: `[*:0]u8` -> `[*:0]const u8`
// 3. add `?` to indicate the item (null-term string) is optional: `[*:0]const u8` → `?[*:0]const u8`
var search0: [2]?[*:0]const u8 = [2]?[*:0]const u8{
user_config_dir,
null,
};
_ = search0;
var search1: [2]?[*:0]const u8 = .{
user_config_dir,
null,
};
_ = search1;
var search2: []const ?[*:0]const u8 = &.{
user_config_dir,
null,
};
_ = search2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment