rust-r1 / README.md
Shadow0482's picture
Add Rust question/code dataset
bae2359 verified
|
Raw History Blame Contribute Delete
2.43 kB
metadata
license: other
task_categories:
  - text-generation
language:
  - en
tags:
  - rust
  - code
  - instruction-tuning
  - synthetic
size_categories:
  - n<1K
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/train-*.parquet

Rust code instruction dataset

126 pairs of (question, real Rust code) built from 1 open-source GitHub repositories.

Each answer is original Rust source. Each question was written by nvidia/nemotron-3.5-lightning-30b-a3b from the code context; the model does not generate the answer.

Source repositories

repository commit license files chunks rows
bee-san/RustScan 937903340a GPL-3.0-only 14 127 126

Rows by kind

kind rows
function 51
method 48
struct 17
enum 5
macro 4
trait 1

Example

Question

I need a function called old_payload_for_port that retrieves a static byte slice payload associated with a given port from a predefined mapping. The mapping is a static BTreeMap where each key is a Vec<u16> representing valid ports, and each value is a Vec<u8> payload. The function should accept a &'static BTreeMap<Vec<u16>, Vec<u8>> and a u16 port, and return a &'static [u8]. It should iterate through the map entries and return the payload of the first entry whose port list contains the given port. If no entry matches, it should return an empty static byte slice.

Answer (bee-san/RustScan - benches/benchmark_helpers.rs)

fn old_payload_for_port(udp_map: &'static BTreeMap<Vec<u16>, Vec<u8>>, port: u16) -> &'static [u8] {
    let mut payload: &'static [u8] = b"";
    for (ports, value) in udp_map.iter() {
        if ports.contains(&port) {
            payload = value.as_slice();
        }
    }
    payload
}

Usage

from datasets import load_dataset

dataset = load_dataset("Shadow0482/rust", split="train")
print(dataset[0]["question"])
print(dataset[0]["answer"])

License and attribution

Code in answer remains under the license of the source repository shown in the license and repo_url columns. Follow that license when redistributing or training on the data. The questions are synthetic; follow the terms of the model provider used to create them.