小编Gio*_*oni的帖子

"考虑删除此分号"错误

在关注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)

rust

3
推荐指数
1
解决办法
208
查看次数

如何在Visual Studio Code中禁用语法着色

我想完全禁用语法着色。

我试图禁用参数提示,但是没有任何效果。

编辑器是否可以仅具有前景色/背景色而没有其他可能?

visual-studio-code

3
推荐指数
3
解决办法
2772
查看次数

String.length和连接字符串

下面的两个表达式产生相同的输出:

> ("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上生成的

f#

0
推荐指数
1
解决办法
755
查看次数

标签 统计

f# ×1

rust ×1

visual-studio-code ×1