Compare commits

...

15 Commits

Author SHA1 Message Date
a29828e8d5 取消安装工具链,改为镜像
Some checks failed
Rust CI Pipeline / test-and-build (push) Has been cancelled
2025-10-21 20:04:30 +08:00
3169f32e4f 减少工作流操作
Some checks failed
Rust CI Pipeline / test-and-build (push) Has been cancelled
2025-10-21 19:51:14 +08:00
9da2086018 添加ci工作流 2025-10-21 19:47:33 +08:00
040d521395 添加构建调试 2025-10-21 14:05:16 +08:00
51a04207ab 移除sercure.md文件 2025-10-19 16:46:11 +08:00
1d411cefb5 first commit 2025-10-19 16:43:45 +08:00
Samruddhi Khandale
d3cb2a9843 Merge pull request #37 from prathameshzarkar9/montly-task-check-devcotainer-json
monthly task update devcontainer.json
2024-04-12 00:36:35 -07:00
“Prathamesh
5ced9d3eca monthly task update devcontainer.json 2024-04-05 13:25:01 +05:30
Samruddhi Khandale
f5b2a7931c Merge pull request #36 from prathameshzarkar9/dependabot-auto-version-update
dependabot auto version update
2024-04-03 16:09:37 -07:00
“Prathamesh
f964546f58 dependabot auto version update 2024-03-22 21:00:55 +05:30
Chuck Lantz
916aa267ca Update template, add features and image metadata info (#28) 2022-12-23 15:27:36 +01:00
Chuck Lantz
cbed25c41b Merge pull request #26 from amir-arad/patch-1
update rust-lang plugin in host
2022-11-28 10:44:37 -06:00
Olivia Guzzardo
da61e6e12c Add SECURITY.md and CODE_OF_CONDUCT.md (#27) 2022-10-28 09:55:00 -07:00
Amir Arad
228542aad9 update rust-lang plugin in host
all the cool language features started to work for me after this change
2022-10-04 21:37:23 +03:00
Brigit Murtaugh
31a0115e26 Update README.md 2022-09-29 09:51:25 +02:00
9 changed files with 157 additions and 124 deletions

View File

@@ -1,8 +0,0 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/rust/.devcontainer/base.Dockerfile
# [Choice] Debian OS version (use bullseye on local arm64/Apple Silicon): buster, bullseye
ARG VARIANT="bullseye"
FROM mcr.microsoft.com/devcontainers/rust:1-${VARIANT}
# [Optional] Uncomment this section to install additional packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

View File

@@ -1,48 +1,57 @@
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.195.0/containers/rust
{
"name": "Rust Sample",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Use the VARIANT arg to pick a Debian OS version: buster, bullseye
// Use bullseye when on local on arm64/Apple Silicon.
"VARIANT": "bullseye"
}
},
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
// Configure tool-specific properties.
"name": "Rust",
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye",
// 先构建项目,但不自动运行
"postStartCommand": "cargo build && clear",
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"lldb.executable": "/usr/bin/lldb",
// VS Code don't watch files under ./target
"files.watcherExclude": {
"**/target/**": true
},
"rust-analyzer.checkOnSave.command": "clippy"
"settings": {},
"extensions": [
"streetsidesoftware.code-spell-checker",
"rust-lang.rust-analyzer", // 添加 Rust 语言支持
"vadimcn.vscode-lldb" // 添加 LLDB 调试器支持
],
// 添加调试配置
"debug": {
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug Rust Application",
"program": "${workspaceFolder}/target/debug/${workspaceFolderBasename}",
"args": [],
"cwd": "${workspaceFolder}",
"preLaunchTask": "cargo-build"
}
]
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"vadimcn.vscode-lldb",
"mutantdino.resourcemonitor",
"matklad.rust-analyzer",
"tamasfe.even-better-toml",
"serayuzgur.crates"
]
// 添加构建任务
"tasks": {
"tasks": [
{
"type": "cargo",
"command": "build",
"problemMatcher": [
"$rustc"
],
"group": "build",
"label": "cargo-build"
}
]
}
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "rustc --version",
// Comment out to run as root instead.
"remoteUser": "vscode"
}
// 转发应用端口(根据你的实际端口修改)
"forwardPorts": [8080],
"portsAttributes": {
"8080": {
"label": "Rust Application",
"onAutoForward": "notify"
}
}
}

41
.gitea/workflows/ci.yaml Normal file
View File

@@ -0,0 +1,41 @@
name: Rust CI Pipeline
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test-and-build:
runs-on: ubuntu-latest
container:
image: ghcr.io/rust-lang/rust:latest
steps:
# 1. 检出代码 - 使用 Gitea 本地的 actions 镜像
- name: 🔍 Check out repository code
uses: https://devstar.cn/actions/checkout@v4
# 2. 显示环境信息
- name: Environment Info
run: |
rustc --version
cargo --version
echo "Building repository: ${{ gitea.repository }}"
# 3. 构建项目(调试模式)
- name: 🔧 Build (Debug)
run: cargo build --verbose
# 4. 构建项目(发布模式)
- name: 🚀 Build (Release)
run: cargo build --release --verbose
# 5. 运行测试
- name: ✅ Run Tests
run: cargo test --verbose
# 6. 清理构建缓存
- name: 🧹 Cleanup
run: cargo clean

7
.vscode/launch.json vendored
View File

@@ -1,4 +1,3 @@
{
"version": "0.2.0",
"configurations": [
@@ -17,7 +16,11 @@
"kind": "bin"
}
},
"args": []
"args": [],
// 添加环境变量解决文件锁问题
"env": {
"CARGO_REGISTRIES_CRATES_IO_PROTOCOL": "sparse"
},
}
]
}

25
.vscode/task.json vendored Normal file
View File

@@ -0,0 +1,25 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "cargo-clean-build",
"type": "process",
"command": "cargo",
"args": [
"build",
"--bin=hello_remote_world",
"--package=hello_remote_world"
],
"group": "build",
"problemMatcher": ["$rustc"],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
}
]
}

9
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,9 @@
# Microsoft Open Source Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
Resources:
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns

View File

@@ -1,7 +1,7 @@
[package]
name = "hello_remote_world"
version = "0.1.0"
authors = ["VS Code <vscode@microsoft.com>"]
edition = "2021"
[lib]
path ="./src/lib/lib.rs"

View File

@@ -1,76 +1,16 @@
# Try Out Development Containers: Rust
# Rust
Rust 基础开发环境镜像模板项目
[![Open in Remote - Containers](https://img.shields.io/static/v1?label=Remote%20-%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/vscode-remote-try-rust)
Rust 项目工程模板
A **development container** is a running [Docker](https://www.docker.com) container with a well-defined tool/runtime stack and its prerequisites. You can try out development containers with **[GitHub Codespaces](https://github.com/features/codespaces)** or **[Visual Studio Code Remote - Containers](https://aka.ms/vscode-remote/containers)**.
## 使用方法
This is a sample project that lets you try out either option in a few easy steps. We have a variety of other [vscode-remote-try-*](https://github.com/search?q=org%3Amicrosoft+vscode-remote-try-&type=Repositories) sample projects, too.
```
cargo run
```
> **Note:** If you already have a Codespace or dev container, you can jump to the [Things to try](#things-to-try) section.
### 版权说明
## Setting up the development container
Copyright @ Mengning Software
### GitHub Codespaces
Follow these steps to open this sample in a Codespace:
1. Click the Code drop-down menu and select the **Open with Codespaces** option.
1. Select **+ New codespace** at the bottom on the pane.
For more info, check out the [GitHub documentation](https://docs.github.com/en/free-pro-team@latest/github/developing-online-with-codespaces/creating-a-codespace#creating-a-codespace).
### VS Code Remote - Containers
If you already have VS Code and Docker installed, you can click the badge above or [here](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/vscode-remote-try-rust) to get started. Clicking these links will cause VS Code to automatically install the Remote - Containers extension if needed, clone the source code into a container volume, and spin up a dev container for use.
Follow these steps to open this sample in a container using the VS Code Remote - Containers extension:
1. If this is your first time using a development container, please ensure your system meets the pre-reqs (i.e. have Docker installed) in the [getting started steps](https://aka.ms/vscode-remote/containers/getting-started).
2. To use this repository, you can either open the repository in an isolated Docker volume:
- Press <kbd>F1</kbd> and select the **Remote-Containers: Try a Sample...** command.
- Choose the "Rust" sample, wait for the container to start, and try things out!
> **Note:** Under the hood, this will use the **Remote-Containers: Clone Repository in Container Volume...** command to clone the source code in a Docker volume instead of the local filesystem. [Volumes](https://docs.docker.com/storage/volumes/) are the preferred mechanism for persisting container data.
Or open a locally cloned copy of the code:
- Clone this repository to your local filesystem.
- Press <kbd>F1</kbd> and select the **Remote-Containers: Open Folder in Container...** command.
- Select the cloned copy of this folder, wait for the container to start, and try things out!
## Things to try
Once you have this sample opened, you'll be able to work with it like you would locally.
> **Note:** This container runs as a non-root user with sudo access by default. Comment out `"remoteUser": "vscode"` in `.devcontainer/devcontainer.json` if you'd prefer to run as root.
Some things to try:
1. **Edit:**
- Open `main.rs`
- Try adding some code and check out the language features.
- Notice that several extensions are already installed in the container, such as Rust support for VS Code, since the `.devcontainer/devcontainer.json` lists a set of extensions, including `"rust-lang.rust"`, to install automatically when the container is created.
1. **Terminal:** Press <kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>\`</kbd> and type `uname` and other Linux commands from the terminal window.
1. **Build, Run, and Debug:**
- Open `main.rs`
- Add a breakpoint (e.g. on line 8).
- Press <kbd>F5</kbd> to launch the app in the container.
- Once the breakpoint is hit, try hovering over variables, examining locals, and more.
## Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
## License
Copyright © Microsoft Corporation All rights reserved.<br />
Licensed under the MIT License. See LICENSE in the project root for license information.
梦宁软件(江苏)有限公司 版权所有

View File

@@ -3,7 +3,21 @@
* Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
*-------------------------------------------------------------------------------------------------------------*/
fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
use std::collections::HashMap;
let mut map = HashMap::new();
for (i, &num) in nums.iter().enumerate() {
if let Some(&j) = map.get(&(target - num)) {
return vec![j as i32, i as i32];
}
map.insert(num, i);
}
vec![]
}
fn main() {
let name = "VS Code Remote - Containers";
println!("Hello, {}!", name);
let nums = vec![2, 7, 11, 15];
let target = 9;
let result = two_sum(nums, target);
println!("{:?}", result); // 输出: [0, 1]
}