Skip to content

基本类型默认有下面4个能力吗 #153

Answered by Demian101
liuyangc3 asked this question in Q&A
Discussion options

You must be logged in to vote

Move 类型的几种能力

  • Copy 被修饰的值可以被复制。
  • Drop 被修饰的值在作用域结束时可以被丢弃。
  • Store 被修饰的值可以被存储到全局状态。
  • Key 被修饰的值可以作为键值对全局状态进行访问。(对应另外一个 value 即 store , key-store 是一对)

用 key,store 修饰,则表示它不能被复制,也不能被丢弃或重新使用,但是它却可以被安全地存储和转移。

struct Counter has key, store {  
	value:u64,  
}

整型、布尔等原生类型天然具有 copy、drop、store 能力。

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by liuyangc3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants