rust - quick start with docker windows

 

To start a docker instance of RUST


docker run -it -v c:\work\rust\app:/app rust /bin/sh

Then using vscode, attach to a running container, choose the rust dev container. Then run the following command 

The following command to create a simple project:

cargo new hello_cargo

cd hello_cargo

cargo build

cargo run


To debug, ensure you have install  the following extension 

- rust-analyzer 

- codelldb


Then use vscode -> Open folder -> then locate your folder in the container. 

You should be able to go to Run->Debug to debug your application, Ensure the intellisense is working as well

Example of my launch.json that was automatically generated :-


{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug executable 'hello_cargo'",
            "cargo": {
                "args": [
                    "build",
                    "--bin=hello_cargo",
                    "--package=hello_cargo"
                ],
                "filter": {
                    "name": "hello_cargo",
                    "kind": "bin"
                }
            },
            "args": [],
            "cwd": "${workspaceFolder}"
        },
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug unit tests in executable 'hello_cargo'",
            "cargo": {
                "args": [
                    "test",
                    "--no-run",
                    "--bin=hello_cargo",
                    "--package=hello_cargo"
                ],
                "filter": {
                    "name": "hello_cargo",
                    "kind": "bin"
                }
            },
            "args": [],
            "cwd": "${workspaceFolder}"
        }
    ]
}


Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm