| ... | ... | @@ -705,34 +705,34 @@ pub fn Vector(comptime len: u32, comptime child: type) type { |
| 705 | 705 | pub fn cast(comptime DestType: type, target: anytype) DestType { |
| 706 | 706 | const TargetType = @TypeOf(target); |
| 707 | 707 | switch (@typeInfo(DestType)) { |
| 708 | | .Pointer => { |
| 708 | .Pointer => |dest_ptr| { |
| 709 | 709 | switch (@typeInfo(TargetType)) { |
| 710 | 710 | .Int, .ComptimeInt => { |
| 711 | 711 | return @intToPtr(DestType, target); |
| 712 | 712 | }, |
| 713 | 713 | .Pointer => |ptr| { |
| 714 | | return @ptrCast(DestType, @alignCast(ptr.alignment, target)); |
| 714 | return @ptrCast(DestType, @alignCast(dest_ptr.alignment, target)); |
| 715 | 715 | }, |
| 716 | 716 | .Optional => |opt| { |
| 717 | 717 | if (@typeInfo(opt.child) == .Pointer) { |
| 718 | | return @ptrCast(DestType, @alignCast(@alignOf(opt.child.Child), target)); |
| 718 | return @ptrCast(DestType, @alignCast(dest_ptr, target)); |
| 719 | 719 | } |
| 720 | 720 | }, |
| 721 | 721 | else => {}, |
| 722 | 722 | } |
| 723 | 723 | }, |
| 724 | | .Optional => |opt| { |
| 725 | | if (@typeInfo(opt.child) == .Pointer) { |
| 724 | .Optional => |dest_opt| { |
| 725 | if (@typeInfo(dest_opt.child) == .Pointer) { |
| 726 | 726 | switch (@typeInfo(TargetType)) { |
| 727 | 727 | .Int, .ComptimeInt => { |
| 728 | 728 | return @intToPtr(DestType, target); |
| 729 | 729 | }, |
| 730 | | .Pointer => |ptr| { |
| 731 | | return @ptrCast(DestType, @alignCast(ptr.alignment, target)); |
| 730 | .Pointer => { |
| 731 | return @ptrCast(DestType, @alignCast(@alignOf(dest_opt.child.Child), target)); |
| 732 | 732 | }, |
| 733 | 733 | .Optional => |target_opt| { |
| 734 | 734 | if (@typeInfo(target_opt.child) == .Pointer) { |
| 735 | | return @ptrCast(DestType, @alignCast(@alignOf(target_opt.child.Child), target)); |
| 735 | return @ptrCast(DestType, @alignCast(@alignOf(dest_opt.child.Child), target)); |
| 736 | 736 | } |
| 737 | 737 | }, |
| 738 | 738 | else => {}, |