`my_func <t:mytrait =“”>`vs`my_func <t>之间的区别T:MyTrait`

时间:2018-03-24 14:37:52

标签: generics rust traits

之间的区别是什么
 get myAccounts(): {name: string, status: string}[] {
   return this.accountsService.accounts;
 }   

constructor(private accountsService: AccountsService) {}

my_func<T: MyTrait>(...) {...}

1 个答案:

答案 0 :(得分:3)

一个用明确的import numpy as np import matplotlib.pyplot as plt from datetime import datetime #makes the data y1 = np.array([123, 456, 789, 10, 5, 123, 456, 789, 10, 5]) y2 = np.array([123, 456, 789, 100, 5, 123, 456, 789, 10, 5]) colors = ['b','g'] #plots the histogram fig, ax1 = plt.subplots() ax1.hist([y1,y2],color=colors) datemin = datetime.strptime('2018-01-01', '%Y-%m-%d') datemax = datetime.strptime('2018-01-10', '%Y-%m-%d') ax1.set_xlim(datemin, datemax) ax1.set_ylabel("Count") plt.tight_layout() plt.show() 条款写,另一个用不是。

好的,好的;如果你想挑剔,差异是:

  • 您不能使用where子句引入通用参数。
  • 您不能在通用参数列表中约束其他的任何内容。

但就将约束从通用参数列表移动到where子句时的更改而言,它们是相同的。