Make Path.fromParts not return error

main
copygirl 1 year ago
parent 8c897607b5
commit f0a956318e
  1. 8
      src/path.zig

@ -88,10 +88,10 @@ pub const Path = struct {
return result;
}
/// Creates a new `Path` from the specified string parts.
/// Creates a new `Path` from the specified parts.
///
/// The resulting path does not own any of the given slices.
pub fn fromParts(absolute: bool, parts: []const EntityPart) !Path {
pub fn fromParts(absolute: bool, parts: []const EntityPart) Path {
std.debug.assert(parts.len > 0);
return .{ .absolute = absolute, .parts = parts };
}
@ -359,7 +359,7 @@ test Path {
// To do this you can use the `buildParts` helper function, which is less
// wordy than building `EntityPart` structs manually.
const absolute1_parts = Path.buildParts(.{ "I'm", "absolute!" });
const absolute1 = try Path.fromParts(true, &absolute1_parts);
const absolute1 = Path.fromParts(true, &absolute1_parts);
// No need to call `deinit()`. The path does not own the `absolute1_parts`
// array nor the string parts, which in this case are comptime constants.
@ -401,7 +401,7 @@ test Path {
// Numeric ids can also be passed to `buildParts`.
const numeric2_parts = Path.buildParts(.{ 100, 101, "bar" });
const numeric2 = try Path.fromParts(false, &numeric2_parts);
const numeric2 = Path.fromParts(false, &numeric2_parts);
try expect(numeric1.equals(numeric2));
// Paths are formattable. As format specifier you can use options defined

Loading…
Cancel
Save