在关注rustbyexample.com教程后,我输入以下代码:
impl fmt::Display for Structure {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let x = format!("{}", "something");
write!(f, "OMG! {}", self.0);
}
}
Run Code Online (Sandbox Code Playgroud)
并从编译器得到以下错误:
error[E0308]: mismatched types
--> src/main.rs:5:58
|
5 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
| __________________________________________________________^
6 | | let x = format!("{}", "something");
7 | | write!(f, "OMG! {}", self.0);
8 | | }
| |_____^ expected enum `std::result::Result`, found ()
|
= note: expected type `std::result::Result<(), std::fmt::Error>`
found …Run Code Online (Sandbox Code Playgroud) 我想完全禁用语法着色。
我试图禁用参数提示,但是没有任何效果。
编辑器是否可以仅具有前景色/背景色而没有其他可能?
下面的两个表达式产生相同的输出:
> ("hello" + " " + "world!");;
val it : string = "hello world!"
> "hello" + " " + "world!";;
val it : string = "hello world!"
Run Code Online (Sandbox Code Playgroud)
为什么然后String.length与第一个一起工作但不与第二个工作?
> String.length ("hello" + " " + "world!");;
val it : int = 12
> String.length "hello" + " " + "world!";;
String.length "hello" + " " + "world!";;
------------------------^^^
stdin(57,25): error FS0001: The type 'string' does not match the type 'int'
Run Code Online (Sandbox Code Playgroud)
这是在FSI 14.0.22214.0上生成的