nvim/.config/nvim/lua/plugins/dap/rust.lua

-- nvim/.config/nvim/lua/plugins/dap/rust.lua
-- codelldb via nvim-dap. rustaceanvim's :RustLsp debug also works.

return {
  "mfussenegger/nvim-dap",
  ft = { "rust" },
  config = function()
    local dap = require("dap")

    local mason_path = vim.fn.stdpath("data") .. "/mason/packages/codelldb"
    local codelldb_path = mason_path .. "/extension/adapter/codelldb"
    local liblldb_path  = mason_path .. "/extension/lldb/lib/liblldb.dylib"

    dap.adapters.codelldb = {
      type = "server",
      port = "${port}",
      executable = {
        command = codelldb_path,
        args    = { "--liblldb", liblldb_path, "--port", "${port}" },
      },
    }

    dap.configurations.rust = {
      {
        name = "launch",
        type = "codelldb",
        request = "launch",
        program = function()
          return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/target/debug/", "file")
        end,
        cwd = "${workspaceFolder}",
        stopOnEntry = false,
        args = {},
        runInTerminal = false,
      },
    }
  end,
}