You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 12, 2024. It is now read-only.
public enum {
case good, bad
public init(isGood: Bool) {
if isGood {
self = .good
}
else {
self = .bad
}
}
public func convertToString() -> String {
if self == .good {
return "Good"
}
else {
return "Bad"
}
}
}
This is tricky in that the distinction between trivial and non-trivial enums has to do with whether or not the have a case with a non-integral payload.
A non-trivial enum is represented by a class that implements ISwiftEnum.
A trivial enum is represented by an enum. We also create a set of extension methods on it.
There are two options here.
The easiest path is to redefine a non-trivial enum as having either a non-trivial enum or having methods. This is not palatable because it adds overhead to all marshaling for that type which should have 0 overhead.
The other path is to put every method into the extension methods. This is possible, but the problem is that every method has to be transformed into a static extension method, which puts them through a completely different code path than either structs or classes or non-trivial enums, which all share the same code paths.
The text was updated successfully, but these errors were encountered:
This is tricky in that the distinction between trivial and non-trivial enums has to do with whether or not the have a case with a non-integral payload.
A non-trivial enum is represented by a class that implements ISwiftEnum.
A trivial enum is represented by an enum. We also create a set of extension methods on it.
There are two options here.
The easiest path is to redefine a non-trivial enum as having either a non-trivial enum or having methods. This is not palatable because it adds overhead to all marshaling for that type which should have 0 overhead.
The other path is to put every method into the extension methods. This is possible, but the problem is that every method has to be transformed into a static extension method, which puts them through a completely different code path than either structs or classes or non-trivial enums, which all share the same code paths.
The text was updated successfully, but these errors were encountered: