Skip to content
New issue

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

建议修改 #71

Closed
AurevoirXavier opened this issue Aug 20, 2017 · 0 comments
Closed

建议修改 #71

AurevoirXavier opened this issue Aug 20, 2017 · 0 comments

Comments

@AurevoirXavier
Copy link

https://kaisery.github.io/trpl-zh-cn/ch10-03-lifetime-syntax.html#结合泛型类型参数trait%20bounds%20和生命周期

这个是列表 10-21 中那个返回两个字符串 slice 中最长者的longest函数,不过带有一个额外的参数ann。ann的类型是泛型T,它可以被放入任何实现了where从句中指定的Display trait 的类型。这个额外的参数会在函数比较字符串 slice 的长度之前被打印出来,这也就是为什么Display trait bound 是必须的。因为生命周期也是泛型,生命周期参数'a和泛型类型参数T都位于函数名后的同一尖括号列表中。


最后一句话改成如下比较好,不然此处一个 ”因为“ 容易引发歧义让读者以为是在解释上一句话中 ”为什么 Display trait bound 是必须的“。

修改:因为生命周期也是泛型,#(所以)生命周期参数'a和泛型类型参数T都位于函数名后的同一尖括号列表中。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants