Last active
December 19, 2022 17:42
-
-
Save mikdusan/637cf6b1b134d2a291ab253492e38bdf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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