【发布时间】:2022-01-12 19:54:37
【问题描述】:
我可以使用 vscode 获得 rust 合约的样板吗?只是入门的基础。要配置 sn-p,我们按 ctrl + shift + p,然后选择“配置用户 sn-ps”。 .rs 和 .toml 文件需要一个 sn-p。只需按前几个字母即可准备好完整的样板文件。
【问题讨论】:
标签: rust code-snippets nearprotocol
我可以使用 vscode 获得 rust 合约的样板吗?只是入门的基础。要配置 sn-p,我们按 ctrl + shift + p,然后选择“配置用户 sn-ps”。 .rs 和 .toml 文件需要一个 sn-p。只需按前几个字母即可准备好完整的样板文件。
【问题讨论】:
标签: rust code-snippets nearprotocol
开始输入“near protocol”以显示 sn-p。
关于 rust sn-p:并非所有项目都需要 serde::{serialize, deserialize}。但无论如何声明它应该不是什么大问题。
.toml sn-p:
"Near BoilerPlate Cargo.toml": {
"prefix": "near protocol",
"body": [
"",
"[lib]",
"crate-type = [\"cdylib\", \"rlib\"]",
"",
"[dependencies]",
"near-sdk = \"3.1.0\"",
"",
"[profile.release]",
"codegen-units = 1",
"# Tell `rustc` to optimize for small code size.",
"opt-level = \"z\"",
"lto = true",
"debug = false",
"panic = \"abort\"",
"overflow-checks = true",
"",
],
"description": "Boilerplate for Creating a rust near contract",
},
锈sn-p:
"NEAR BoilerPlate lib.rs": {
"prefix": "near protocol",
"body": [
"use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};",
"#[allow(unused_imports)]",
"use near_sdk::{env, near_bindgen};",
"use near_sdk::serde::{Deserialize, Serialize};",
"",
"",
"near_sdk::setup_alloc!();",
"",
"",
"#[near_bindgen]",
"#[derive(Clone, Default, Serialize, Deserialize, BorshDeserialize, BorshSerialize)]",
"#[serde(crate = \"near_sdk::serde\")]",
"pub struct Contract {",
"",
"}",
"",
"#[near_bindgen]",
"impl Contract{",
"",
"}",
],
"description": "BoilerPlate for Creating a near contract"
},
【讨论】: