My environment

SYSTEM: macOS 11.2.3

LANGUAEG: Rust

If you cannot log in to LeetCode using your account, you can log in using cookies

change code template

Need to modify the ~ /. Vscode/extensions/leetcode vscode – leetcode – 0.18.0 / node_modules/VSC – leetcode – cli/templates/codeonly TPL

#[allow(dead_code)]
pub struct Solution {}

${comment.start}
${comment.line} @lc app=${app} id=${fid} lang=${lang}
${comment.line}
${comment.line} [${fid}] ${name}
${comment.end}

${comment.singleLine} @lc code=start
${code}
${comment.singleLine} @lc code=end
Copy the code

how debug in local

Adjust the leetcode configuration in setting.json

"leetcode.workspaceFolder": "/Users/yiniau/project/leetcode"."leetcode.endpoint": "leetcode"."leetcode.filePath": {
"rust": {
    "folder": "./src"."filename": "${snake_case_name}_${id}.${ext}"
},
"default": {
	"folder": ""."filename": "${id}.${kebab-case-name}.${ext}"}},"leetcode.defaultLanguage": "rust"
Copy the code

After pulling down the problem code, the corresponding file will appear under SRC. Take problem 605 as an example

src
|- can_place_flowers_605.rs
|- main.rs
Cargo.toml
Cargo.lock
Copy the code

To add the reference and write the test code manually in main, just copy the file name. Select the file on your MAC and press Ctrl -v

#[path="./can_place_flowers_605.rs"]
mod can_place_flowers_605;

fn main() {
    println!("hello world");
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn can_place_flowers_605() {
        assert_eq!(
            can_place_flowers_605::Solution::can_place_flowers(vec![1.0.0.0.1].1),
            true
        );
        assert_eq!(
            can_place_flowers_605::Solution::can_place_flowers(vec![1.0.0.0.1].2),
            false); }}Copy the code