[英]This code will never be executed warning swift equatable enum
I have this code from a 3rd party library:我有一个来自 3rd 方库的代码:
public enum NoError: Swift.Error, Equatable {
public static func ==(lhs: NoError, rhs: NoError) -> Bool {
return true
}
}
This generates the warning : 1. 'lhs' is uninhabited, so this function body can never be executed This will never be executed这会产生警告: 1. 'lhs' is uninhabited,所以这个函数体永远不会被执行 这永远不会被执行
How could I get rid of this warning?我怎样才能摆脱这个警告?
enum
should have case
. enum
应该有case
。 I mean enumeration should have definition.我的意思是枚举应该有定义。 I don't understand why
enum
uses here, because it's can be class
.我不明白为什么
enum
在这里使用,因为它可以是class
。 However, this will work without warnings:但是,这将在没有警告的情况下工作:
public enum NoError: Swift.Error, Equatable {
case case1
case case2
public static func ==(lhs: NoError, rhs: NoError) -> Bool {
return true
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.