Skip to content

Commit

Permalink
rust方法
Browse files Browse the repository at this point in the history
  • Loading branch information
realgeoffrey committed Aug 21, 2024
1 parent bf8ae96 commit bb8d96e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 网站前端/Rust学习笔记/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
2. 函数可以向调用它的代码返回值,但必须在箭头(`->`)后声明它的类型。每个可能的返回值都必须是这个类型;否则报错。
在 Rust 中,函数的返回值等同于函数体最后一个表达式的值。使用 return 关键字和指定值,可从函数中提前返回;但大部分函数隐式的返回最后的表达式。
1 方法(method)
1. 方法(method)
(与函数类似,它们使用 fn 关键字和名称声明,可以拥有参数和返回值,同时包含在某处调用该方法时会执行的代码。不过方法与函数是不同的,因为它们在结构体的上下文中被定义(或者是枚举或 trait 对象的上下文),并且它们第一个参数总是 self,它代表调用该方法的结构体实例。
Expand Down

0 comments on commit bb8d96e

Please sign in to comment.