-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from tishin/fix-struct-members
Limit struct stored property generation to members with offsets
- Loading branch information
Showing
3 changed files
with
62 additions
and
34 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// Endable.swift | ||
// | ||
// | ||
// Created by Mikhail Tishin on 15.10.2023. | ||
// | ||
|
||
public protocol Endable { | ||
|
||
associatedtype VectorType: AdditiveArithmetic | ||
|
||
var position: VectorType { get } | ||
var size: VectorType { get set } | ||
|
||
} | ||
|
||
public extension Endable { | ||
|
||
var end: VectorType { | ||
set { | ||
size = newValue - position | ||
} | ||
get { | ||
return position + size | ||
} | ||
} | ||
|
||
} | ||
|
||
extension Vector2: AdditiveArithmetic {} | ||
extension Vector2i: AdditiveArithmetic {} | ||
extension Vector3: AdditiveArithmetic {} | ||
extension Vector3i: AdditiveArithmetic {} | ||
|
||
extension AABB: Endable {} | ||
extension Rect2: Endable {} | ||
extension Rect2i: Endable {} |