We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
13.2.2
子类型与型变
Fn(T) -> U 在 T 上是不变,在 U 上是协变。
按照 我测试的结果 ,Fn 在 T 上应该是逆变的。
Fn
T
同理,第 494 页第二行,“普通的函数调用,参数是不变”,但实际上也是逆变的:一个类型为 &'a str 的形参永远可以传一个 &'static str 的实参进去。
&'a str
&'static str
PS:感觉这里实际上应该用 fn(T) -> U ? fn 类型比 Fn trait 更加基础重要一些。 PS2:493 页就写了 PhantomData<fn(T)> 在 T 上是逆变 😂
fn(T) -> U
fn
PhantomData<fn(T)>
The text was updated successfully, but these errors were encountered:
@mzji 感谢反馈。我来调研一下。
Sorry, something went wrong.
结果如何
@acodercat 他说的应该是对的,还没抽出时间看这块
No branches or pull requests
页码与行数
文本或排版错误
按照 我测试的结果 ,
Fn
在T
上应该是逆变的。同理,第 494 页第二行,“普通的函数调用,参数是不变”,但实际上也是逆变的:一个类型为
&'a str
的形参永远可以传一个&'static str
的实参进去。PS:感觉这里实际上应该用
fn(T) -> U
?fn
类型比Fn
trait 更加基础重要一些。PS2:493 页就写了
PhantomData<fn(T)>
在T
上是逆变 😂The text was updated successfully, but these errors were encountered: