5
考慮下面的例子誤差在模式匹配
我得到這個誤差
error: the type of this value must be known in this conntext
true => str.chars().map(|x| x.to_lowercase()).collect().as_slice()
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
我有點混亂「類型,此值必須在此上下文中被稱爲」編譯器是否知道函數定義中str
的類型是&str
?我在這裏錯過了什麼?
謝謝。我最終使用臨時變量來存儲'String'並將其綁定到'temp_var.as_slice()'。不知道是否有更好的方法。 – 2014-09-13 11:56:19