File size: 2,430 Bytes
bae2359
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---

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](https://github.com/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`)

```rust

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

```python

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.