mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
Add unwrapConst, avoid constCast
This commit is contained in:
@ -189,7 +189,7 @@ pub fn getIndex(
|
||||
var i: usize = 0;
|
||||
var it = self.faces.get(style).constIterator(0);
|
||||
while (it.next()) |entry_or_alias| {
|
||||
if (@constCast(entry_or_alias).unwrap().hasCodepoint(cp, p_mode)) {
|
||||
if (entry_or_alias.unwrapConst().hasCodepoint(cp, p_mode)) {
|
||||
return .{
|
||||
.style = style,
|
||||
.idx = @intCast(i),
|
||||
@ -215,7 +215,7 @@ pub fn hasCodepoint(
|
||||
) bool {
|
||||
const list = self.faces.get(index.style);
|
||||
if (index.idx >= list.count()) return false;
|
||||
return @constCast(list.at(index.idx)).unwrap().hasCodepoint(cp, p_mode);
|
||||
return list.at(index.idx).unwrapConst().hasCodepoint(cp, p_mode);
|
||||
}
|
||||
|
||||
pub const CompleteError = Allocator.Error || error{
|
||||
@ -770,6 +770,13 @@ pub const EntryOrAlias = union(enum) {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn unwrapConst(self: *const EntryOrAlias) *const Entry {
|
||||
return switch (self.*) {
|
||||
.entry => |*v| v,
|
||||
.alias => |v| v,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn unwrapNoAlias(self: *EntryOrAlias) ?*Entry {
|
||||
return switch (self.*) {
|
||||
.entry => |*v| v,
|
||||
|
Reference in New Issue
Block a user