text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let responses = self
.outgoing_responses
.into_iter()
.map(|(id, metadata)| {
let metadata = forest_encoding::to_vec(&metadata).map_err(|e| e.to_string())?;
let mut extensions = extensions.remove(&id).unwrap_or_default();
... | code_fim | hard | {
"lang": "rust",
"repo": "creativcoder/forest",
"path": "/ipld/graphsync/src/response_manager/response_builder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> builder.complete(request_ids[3], ResponseStatusCode::RequestCompletedFull);
for block in &data {
builder.add_block(block.clone());
}
assert_eq!(builder.block_size(), 300);
let extension1 = ExtensionData {
name: "AppleSauce/McGee".to_string... | code_fim | hard | {
"lang": "rust",
"repo": "creativcoder/forest",
"path": "/ipld/graphsync/src/response_manager/response_builder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
println!("Bit and: {}\n", f2() & f1()); // 按位与
println!("Bit and: {}\n", f2() && f1()); // 逻辑与
println!("Logic or: {}\n", f1() | f2()); // 按位或
println!("Logic or: {}\n", f1() || f2()); // 按位与
}<|fim_prefix|>// repo: lx70770/rust-learn path: /src/logic.rs
fn f1() -> bool {
... | code_fim | easy | {
"lang": "rust",
"repo": "lx70770/rust-learn",
"path": "/src/logic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lx70770/rust-learn path: /src/logic.rs
fn f1() -> bool {
println!("call f1");
true
}
<|fim_suffix|>fn main() {
println!("Bit and: {}\n", f2() & f1()); // 按位与
println!("Bit and: {}\n", f2() && f1()); // 逻辑与
println!("Logic or: {}\n", f1() | f2()); // 按位或
println!("Logic o... | code_fim | easy | {
"lang": "rust",
"repo": "lx70770/rust-learn",
"path": "/src/logic.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let stories = document.select("h3.notice + table").iter().next();
let stories = stories
.into_iter()
.flat_map(|x| x.select("td a").iter().filter_map(|x| x.attr("href")))
.map(RelativeUrl);
Ok(DirectoryUrls {
urls: stories.map(|story... | code_fim | hard | {
"lang": "rust",
"repo": "kcbyo/klit",
"path": "/src/adapter/sexstories.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kcbyo/klit path: /src/adapter/sexstories.rs
use super::prelude::*;
pub struct BuildSexStoriesAdapter;
impl BuildAdapter for BuildSexStoriesAdapter {
fn build(&self) -> Box<dyn Adapter + 'static> {
Box::new(SexStoriesAdapter::new())
}
}
pub struct SexStoriesAdapter {
client... | code_fim | hard | {
"lang": "rust",
"repo": "kcbyo/klit",
"path": "/src/adapter/sexstories.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(DirectoryUrls {
urls: stories.map(|story| story.url()).collect(),
page: None,
meta,
})
}
fn download(&self, context: DocumentUrl) -> Result<Document> {
let text = self.client.get(&context.url).send()?.text()?;
let document = n... | code_fim | hard | {
"lang": "rust",
"repo": "kcbyo/klit",
"path": "/src/adapter/sexstories.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aclueless/rustmart-examples path: /rustmart-yew-fewer-components/src/views/navbar.rs
use crate::types::CartProduct;
use yew::prelude::*;
<|fim_suffix|> html! {
<div class="navbar">
<div class="navbar_title">{"RustMart"}</div>
<div class="navbar_cart_value">{fo... | code_fim | medium | {
"lang": "rust",
"repo": "aclueless/rustmart-examples",
"path": "/rustmart-yew-fewer-components/src/views/navbar.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> html! {
<div class="navbar">
<div class="navbar_title">{"RustMart"}</div>
<div class="navbar_cart_value">{format!("${:.2}", cart_value)}</div>
</div>
}
}<|fim_prefix|>// repo: aclueless/rustmart-examples path: /rustmart-yew-fewer-components/src/views/navbar... | code_fim | medium | {
"lang": "rust",
"repo": "aclueless/rustmart-examples",
"path": "/rustmart-yew-fewer-components/src/views/navbar.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: biluohc/Box path: /exprc/src/main.rs
pub mod c;
use std::env;
fn main() {
let mut args = env::args().skip(1).collect::<Vec<String>>();
if args.len() == 0 {
println!(
"Exprc need args !
Exprc support +-*/ and assgin(=): a=123; a*(2-1)/3
Exprc will go ... | code_fim | hard | {
"lang": "rust",
"repo": "biluohc/Box",
"path": "/exprc/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if c.current_tok == c::Token::End {
break;
}
if c.current_tok == c::Token::Print {
continue;
}
let rest = c.expr(false)?;
println!("{} = {}", c.recent_unassign, rest);
c.name_number_map.insert(c.recent_unassign.to_owned(), re... | code_fim | hard | {
"lang": "rust",
"repo": "biluohc/Box",
"path": "/exprc/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.id == other.id
}
}
impl Eq for State<'_> {}
impl std::fmt::Debug for State<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("State")
.field("time", &self.time)
.field("stockpile", &self.stockpile)
.f... | code_fim | hard | {
"lang": "rust",
"repo": "qualiaa/aoc",
"path": "/2022/19/ab.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut time = 0;
for &m in Material::iter() {
let n = recipe.cost(m);
if n == 0 { continue }
let dn = self.production.amount(m);
if dn == 0 { return None }
let n = n.saturating_sub(self.stockpile.amount(m)) as isize;
... | code_fim | hard | {
"lang": "rust",
"repo": "qualiaa/aoc",
"path": "/2022/19/ab.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qualiaa/aoc path: /2022/19/ab.rs
#![feature(let_chains)]
#![feature(impl_trait_projections)]
#![feature(result_option_inspect)]
use std::collections::{BinaryHeap, HashMap};
use std::cmp::{Ordering, PartialOrd, Ord, Reverse};
use std::error::Error;
use std::ops::{Add, Mul, MulAssign, Sub, AddAss... | code_fim | hard | {
"lang": "rust",
"repo": "qualiaa/aoc",
"path": "/2022/19/ab.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct Inputs {
season: String,
guests: i32,
}
impl Inputs {
fn new(season: String, guests: String) -> Inputs {
Inputs {
season: season.trim().to_string(),
guests: guests.trim().parse::<i32>().expect("unable to convert int"),
}
}
}
impl ToJson for ... | code_fim | medium | {
"lang": "rust",
"repo": "hemanthkodandarama/camunda-dmn-cloud-examples",
"path": "/rust/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hemanthkodandarama/camunda-dmn-cloud-examples path: /rust/src/main.rs
extern crate hyper;
extern crate rustc_serialize;
use std::io::{self, Read, Write};
use std::collections::BTreeMap;
use hyper::client::Client;
use hyper::header::ContentType;
use rustc_serialize::json::{self, ToJson, Json};... | code_fim | hard | {
"lang": "rust",
"repo": "hemanthkodandarama/camunda-dmn-cloud-examples",
"path": "/rust/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut body = String::new();
res.read_to_string(&mut body).expect("unable to parse reponse");
let json: DecisionResult = json::decode(&body).expect("unable to transform json");
let result = &json.outputs["dish"].values[0];
println!("You should have {}", result);
}<|fim_prefix|>// rep... | code_fim | hard | {
"lang": "rust",
"repo": "hemanthkodandarama/camunda-dmn-cloud-examples",
"path": "/rust/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let kv_driver = components::kv_system::KVDriverComponent::new(
kv_store,
board_kernel,
capsules_extra::kv_driver::DRIVER_NUM,
)
.finalize(components::kv_driver_component_static!(
capsules_extra::tickv::TicKVStore<
capsules_core::virtualizers::virtual... | code_fim | hard | {
"lang": "rust",
"repo": "lowRISC/opentitan",
"path": "/sw/device/silicon_owner/tock/kernel/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Need to enable all interrupts for Tock Kernel
chip.enable_plic_interrupts();
// enable interrupts globally
csr::CSR.mie.modify(
csr::mie::mie::msoft::SET + csr::mie::mie::mtimer::CLEAR + csr::mie::mie::mext::SET,
);
csr::CSR.mstatus.modify(csr::mstatus::mstatus::mie::SET... | code_fim | hard | {
"lang": "rust",
"repo": "lowRISC/opentitan",
"path": "/sw/device/silicon_owner/tock/kernel/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lowRISC/opentitan path: /sw/device/silicon_owner/tock/kernel/src/main.rs
memory_allocation_cap)
)
);
hil::time::Alarm::set_alarm_client(virtual_alarm_user, alarm);
let scheduler_timer = static_init!(
VirtualSchedulerTimer<VirtualMuxAlarm<'static, earlgrey::timer::RvT... | code_fim | hard | {
"lang": "rust",
"repo": "lowRISC/opentitan",
"path": "/sw/device/silicon_owner/tock/kernel/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // the GRANDPA voter task is considered infallible, i.e.
// if it fails we take down the service with it.
service.spawn_essential_task(grandpa::run_grandpa_voter(voter_config)?);
},
(_, true) => {
grandpa::setup_disabled_grandpa(
service.client(),
&inherent_data_providers,
serv... | code_fim | hard | {
"lang": "rust",
"repo": "gnunicorn/substrate-offchain-cb",
"path": "/src/service.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnunicorn/substrate-offchain-cb path: /src/service.rs
//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
use std::sync::Arc;
use std::time::Duration;
use substrate_client::LongestChain;
use babe::{import_queue, start_babe, Config};
use grandpa::{self, Fin... | code_fim | hard | {
"lang": "rust",
"repo": "gnunicorn/substrate-offchain-cb",
"path": "/src/service.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> let babe = start_babe(babe_config)?;
let select = babe.select(service.on_exit()).then(|_| Ok(()));
// the BABE authoring task is considered infallible, i.e. if it
// fails we take down the service with it.
service.spawn_essential_task(select);
}
let grandpa_config = grandpa::Config {
// FI... | code_fim | hard | {
"lang": "rust",
"repo": "gnunicorn/substrate-offchain-cb",
"path": "/src/service.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Returns the index of the char index that is different. None if same or more than one differences.
fn find_one_diff(str_a: &str, str_b: &str) -> Option<usize> {
let mut index = 0;
let mut diff_pos = None;
// Compare every char
for (char_a, char_b) in str_a.chars().zip(str_b.chars()) {
... | code_fim | hard | {
"lang": "rust",
"repo": "TechGuard/advent_of_code_2018",
"path": "/day02/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (offset, &line1) in lines.iter().enumerate() {
for &line2 in lines.iter().skip(offset + 1) {
// Find the one and only difference
if let Some(diff_pos) = find_one_diff(line1, line2) {
// Copy line1 and remove char at diff_pos
let mut a... | code_fim | medium | {
"lang": "rust",
"repo": "TechGuard/advent_of_code_2018",
"path": "/day02/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TechGuard/advent_of_code_2018 path: /day02/src/main.rs
use std::collections::HashMap;
use std::io::{self, Read};
fn main() {
let mut input = String::new();
io::stdin()
.read_to_string(&mut input)
.expect("Expected input");
println!("1st Answer = {}", get_answer1(&in... | code_fim | medium | {
"lang": "rust",
"repo": "TechGuard/advent_of_code_2018",
"path": "/day02/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: happysalada/poem path: /examples/openapi/hello-world/src/main.rs
use poem::{listener::TcpListener, Route};
use poem_openapi::{param::Query, payload::PlainText, OpenApi, OpenApiService};
struct Api;
#[OpenApi]
impl Api {
#[oai(path = "/hello", method = "get")]
async fn index(&self, name... | code_fim | hard | {
"lang": "rust",
"repo": "happysalada/poem",
"path": "/examples/openapi/hello-world/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: citronneur/mignosaurus path: /src/asset/mod.rs
use system::render::{SpriteRef, load};
use component::physics::BoundingBox;
use std::collections::HashMap;
use blit::BlitBuffer;
<|fim_suffix|>
pub fn update(manager: &mut AssetManager, name: String, bitmap: &'static[u32], bbox: BoundingBox) {
... | code_fim | hard | {
"lang": "rust",
"repo": "citronneur/mignosaurus",
"path": "/src/asset/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub type AssetManager<> = HashMap<String, (SpriteRef, BoundingBox, &'static[u32])>;
pub fn update(manager: &mut AssetManager, name: String, bitmap: &'static[u32], bbox: BoundingBox) {
let sprite_ref = {
let sprite = BlitBuffer::from_buffer(bitmap, bbox.x as i32, 0x0);
// Load the spr... | code_fim | hard | {
"lang": "rust",
"repo": "citronneur/mignosaurus",
"path": "/src/asset/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Error, Debug)]
pub enum SftpError {
#[error("A TCP error connecting to server. ({0:?})")]
TcpError(#[from] std::io::Error),
#[error("An SSH error connecting to server. ({0:?})")]
Ssh2Error(#[from] async_ssh2::Error),
#[error("File could not be retrieved on server")]
CouldN... | code_fim | medium | {
"lang": "rust",
"repo": "MHRA/products",
"path": "/medicines/doc-index-updater/src/storage_client/models.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MHRA/products path: /medicines/doc-index-updater/src/storage_client/models.rs
use azure_sdk_core::errors::AzureError;
use base64::DecodeError;
use thiserror::Error;
pub struct StorageFile {
pub name: String,
pub path: String,
}
#[derive(Error, Debug)]
pub enum StorageClientError {
... | code_fim | medium | {
"lang": "rust",
"repo": "MHRA/products",
"path": "/medicines/doc-index-updater/src/storage_client/models.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let opts = &[
optflag("b", "number non-blank lines", "Number the non-blank output lines, starting at 1."),
optflag("s", "squeeze", "Squeeze multiple adjacent empty lines, causing the output to be single spaced."),
optflag("b", "number non-blank", "Number the non-blank output li... | code_fim | medium | {
"lang": "rust",
"repo": "lukeasrodgers/rust-cat",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lukeasrodgers/rust-cat path: /src/main.rs
extern crate getopts;
extern crate "rust-cat" as rustcat;
use getopts::{optflag,getopts,OptGroup,usage};
use std::os;
use rustcat::{print_usage,cat};
fn main() {
let args: Vec<String> = os::args();
<|fim_suffix|> let opts = &[
optflag(... | code_fim | medium | {
"lang": "rust",
"repo": "lukeasrodgers/rust-cat",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SoundRabbit/soldoresol path: /src/libs/three/cameras.rs
use wasm_bindgen::prelude::*;
use super::Object3D;
#[wasm_bindgen(module = "three")]
extern "C" {
#[wasm_bindgen(extends = Object3D)]
pub type Camera;
<|fim_suffix|> #[wasm_bindgen(method, setter, js_name = "left")]
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "SoundRabbit/soldoresol",
"path": "/src/libs/three/cameras.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[wasm_bindgen(method, setter, js_name = "left")]
pub fn set_left(this: &OrthographicCamera, left: f64);
#[wasm_bindgen(method, setter, js_name = "bottom")]
pub fn set_bottom(this: &OrthographicCamera, bottom: f64);
#[wasm_bindgen(method, setter, js_name = "right")]
pub fn set_ri... | code_fim | hard | {
"lang": "rust",
"repo": "SoundRabbit/soldoresol",
"path": "/src/libs/three/cameras.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[wasm_bindgen(method, setter, js_name = "aspect")]
pub fn set_aspect(this: &PerspectiveCamera, aspect: f64);
}
#[wasm_bindgen(module = "three")]
extern "C" {
#[wasm_bindgen(extends = Camera)]
pub type OrthographicCamera;
#[wasm_bindgen(constructor)]
pub fn new(
left: f64... | code_fim | medium | {
"lang": "rust",
"repo": "SoundRabbit/soldoresol",
"path": "/src/libs/three/cameras.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Length
#[structopt(long, default_value = "52")]
length: usize,
/// Seconds of delay between transmits. Set to 0 for one-shot
#[structopt(long, default_value = "0")]
delay: u64,
/// Transmit frequency in MHz
#[structopt(long, default_value = "868.1")]
frequency: f6... | code_fim | hard | {
"lang": "rust",
"repo": "isabella232/semtech-udp",
"path": "/examples/server_split.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Seconds of delay between transmits. Set to 0 for one-shot
#[structopt(long, default_value = "0")]
delay: u64,
/// Transmit frequency in MHz
#[structopt(long, default_value = "868.1")]
frequency: f64,
/// Spreading Factor (eg: SF12)
#[structopt(long, default_value = "S... | code_fim | hard | {
"lang": "rust",
"repo": "isabella232/semtech-udp",
"path": "/examples/server_split.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isabella232/semtech-udp path: /examples/server_split.rs
use semtech_udp::{
pull_resp,
server_runtime::{Event, UdpRuntime},
Bandwidth, CodingRate, DataRate, MacAddress, Modulation, SpreadingFactor, StringOrNum,
};
use std::net::SocketAddr;
use structopt::StructOpt;
use tokio::sync::on... | code_fim | hard | {
"lang": "rust",
"repo": "isabella232/semtech-udp",
"path": "/examples/server_split.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lynskylate/serde_hessian path: /hessian/benches/hessian_benchmark.rs
use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
use hessian_rs::{from_slice, to_vec};
<|fim_suffix|> let mut group = c.benchmark_group("decode");
group.throughput(Throughput::Bytes(IN... | code_fim | medium | {
"lang": "rust",
"repo": "Lynskylate/serde_hessian",
"path": "/hessian/benches/hessian_benchmark.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut group = c.benchmark_group("decode");
group.throughput(Throughput::Bytes(INPUT.len() as u64));
group.bench_function("from_slice", |b| {
b.iter(|| {
from_slice(black_box(INPUT)).unwrap();
})
});
group.bench_function("from_slice_to_vec", |b| {
b... | code_fim | medium | {
"lang": "rust",
"repo": "Lynskylate/serde_hessian",
"path": "/hessian/benches/hessian_benchmark.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl_euclidean_int!(@UNIT *self => $($tt)*)
}
#[inline]
fn euclid_div(&self, rhs: Self) -> (Self, Self) {
(self / rhs, self % rhs)
}
}
};
}
macro_rules! impl_euclidean_float {
($($set:ident)*) => {
$(... | code_fim | hard | {
"lang": "rust",
"repo": "TriedWorks/fructose",
"path": "/src/properties/euclidean.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn euclid_norm(&self) -> Self::Norm {
self.abs()
}
#[inline]
fn euclid_div(&self, rhs: Self) -> (Self, Self) {
(self / rhs, self % rhs)
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "TriedWorks/fructose",
"path": "/src/properties/euclidean.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TriedWorks/fructose path: /src/properties/euclidean.rs
use crate::algebra::ring::EuclideanSemidomain;
pub trait EuclideanDiv: Sized {
type Norm: EuclideanSemidomain + PartialOrd;
fn euclid_norm(&self) -> Self::Norm;
fn euclid_div_quotient(&self, rhs: Self) -> Self {
let (q... | code_fim | hard | {
"lang": "rust",
"repo": "TriedWorks/fructose",
"path": "/src/properties/euclidean.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>Dimension_t,
pub SpreaderArea: CellDimension_t,
pub SinkMaterial: Material_t,
pub SpreaderMaterial: Material_t,
}<|fim_prefix|>// repo: markov-chain/3d-ice-sys path: /src/heat_sink.rs
use material::*;
use types::*;
#[derive(Clone, Copy)]
#[repr(C)]
pub struct HeatSink_t {
pub SinkModel: ... | code_fim | hard | {
"lang": "rust",
"repo": "markov-chain/3d-ice-sys",
"path": "/src/heat_sink.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: markov-chain/3d-ice-sys path: /src/heat_sink.rs
use material::*;
use types::*;
#[derive(Clone, Copy)]
#[repr(C)]
pub struct HeatSink_t {
pub SinkModel: HeatSinkModel_t<|fim_suffix|>Dimension_t,
pub SpreaderArea: CellDimension_t,
pub SinkMaterial: Material_t,
pub SpreaderMaterial... | code_fim | hard | {
"lang": "rust",
"repo": "markov-chain/3d-ice-sys",
"path": "/src/heat_sink.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>erature: Temperature_t,
pub SinkHeight: CellDimension_t,
pub SinkArea: CellDimension_t,
pub SpreaderHeight: CellDimension_t,
pub SpreaderArea: CellDimension_t,
pub SinkMaterial: Material_t,
pub SpreaderMaterial: Material_t,
}<|fim_prefix|>// repo: markov-chain/3d-ice-sys path: /sr... | code_fim | medium | {
"lang": "rust",
"repo": "markov-chain/3d-ice-sys",
"path": "/src/heat_sink.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[allow(dead_code)]
pub fn reset(&mut self) {
// TODO
}
pub fn frame(&mut self) {
let mut frame_clock = self.cpu.t + FRAME_TIME;
// TODO: Figure out if this runs the correct number of times
while frame_clock > 0 {
let m_cycles = self.cpu.exec(&... | code_fim | hard | {
"lang": "rust",
"repo": "justinsacbibit/dmg",
"path": "/src/dmg.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: justinsacbibit/dmg path: /src/dmg.rs
use super::mmu::Mmu;
use super::cpu::Cpu;
use super::gpu::Gpu;
// The number of clock cycles it takes to render a single frame
const FRAME_TIME: u32 = 70224;
<|fim_suffix|> // memory management unit
mmu: Mmu,
// graphics processing unit
gpu:... | code_fim | medium | {
"lang": "rust",
"repo": "justinsacbibit/dmg",
"path": "/src/dmg.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nrf-rs/nrf9160-pac path: /src/spu_s/flashnsc.rs
#[doc = "Description cluster: Define which flash region can contain the non-secure callable (NSC) region n\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [... | code_fim | hard | {
"lang": "rust",
"repo": "nrf-rs/nrf9160-pac",
"path": "/src/spu_s/flashnsc.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|>lable fields see [size](size) module"]
pub type SIZE = crate::Reg<u32, _SIZE>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SIZE;
#[doc = "`read()` method returns [size::R](size::R) reader structure"]
impl crate::Readable for SIZE {}
#[doc = "`write(|w| ..)` method takes [size::W](size::W) writer str... | code_fim | hard | {
"lang": "rust",
"repo": "nrf-rs/nrf9160-pac",
"path": "/src/spu_s/flashnsc.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Sarrg/etterna-graph path: /savegame_analysis/src/rescore.rs
use itertools::izip;
mod matching_scorer;
pub use matching_scorer::MatchingScorer;
mod naive_scorer;
pub use naive_scorer::NaiveScorer;
pub struct ScoringResult {
wifescore_sum: f32,
num_judged_notes: u64,
}
/// Trait for a score... | code_fim | hard | {
"lang": "rust",
"repo": "Sarrg/etterna-graph",
"path": "/savegame_analysis/src/rescore.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> wifescore_sum += column_scoring_result.wifescore_sum;
num_judged_notes += column_scoring_result.num_judged_notes;
}
wifescore_sum += W::MINE_HIT_WEIGHT * num_mine_hits as f32;
wifescore_sum += W::HOLD_DROP_WEIGHT * num_hold_drops as f32;
let wifescore = wifescore_sum / num_judged_notes as f32;
... | code_fim | hard | {
"lang": "rust",
"repo": "Sarrg/etterna-graph",
"path": "/savegame_analysis/src/rescore.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aws/s2n-tls path: /bindings/rust/s2n-tls-sys/build.rs
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use std::path::{Path, PathBuf};
fn main() {
let external = External::default();
if external.is_enabled() {
external... | code_fim | hard | {
"lang": "rust",
"repo": "aws/s2n-tls",
"path": "/bindings/rust/s2n-tls-sys/build.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let lib_dir = option_env("S2N_TLS_LIB_DIR")
.map(PathBuf::from)
.or_else(|| dir.as_ref().map(|d| d.join("lib")));
let include_dir = option_env("S2N_TLS_INCLUDE_DIR")
.map(PathBuf::from)
.or_else(|| dir.as_ref().map(|d| d.join("include")));
... | code_fim | hard | {
"lang": "rust",
"repo": "aws/s2n-tls",
"path": "/bindings/rust/s2n-tls-sys/build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !pq {
build.define("S2N_NO_PQ", "1");
}
let out_dir = PathBuf::from(env("OUT_DIR"));
let features = FeatureDetector::new(&out_dir);
let mut feature_names = std::fs::read_dir("lib/tests/features")
.expect("missing features directory")
.flatten()
.fi... | code_fim | hard | {
"lang": "rust",
"repo": "aws/s2n-tls",
"path": "/bindings/rust/s2n-tls-sys/build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn overlaps_circle(&self, circle: &Circle) -> bool {
self.top.intersects_circle(circle)
|| self.right.intersects_circle(circle)
|| self.bottom.intersects_circle(circle)
|| self.left.intersects_circle(circle)
}
pub fn overlaps_ellipse(&self, elli... | code_fim | hard | {
"lang": "rust",
"repo": "fakemonster/just-asc",
"path": "/src/shapes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sqrt_discriminant = discriminant.sqrt();
let t1 = (-b + sqrt_discriminant) / (2. * a);
let t2 = (-b - sqrt_discriminant) / (2. * a);
(0. < t1 && t1 < 1.) || (0. < t2 && t2 < 1.)
}
}
// a pair of points defining the bounds, with some precomputed values
#[derive(Deb... | code_fim | hard | {
"lang": "rust",
"repo": "fakemonster/just-asc",
"path": "/src/shapes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fakemonster/just-asc path: /src/shapes.rs
#[derive(Debug, Clone)]
pub struct Point {
pub x: f64,
pub y: f64,
}
impl Point {
pub fn new(x: f64, y: f64) -> Self {
Point { x, y }
}
fn rotate(&self, axis: &Point, keel: f64) -> Point {
let s = keel.sin();
... | code_fim | hard | {
"lang": "rust",
"repo": "fakemonster/just-asc",
"path": "/src/shapes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: housleyjk/rust-smtp path: /src/client/authentication.rs
// Copyright 2014 Alexis Mousset. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT l... | code_fim | hard | {
"lang": "rust",
"repo": "housleyjk/rust-smtp",
"path": "/src/client/authentication.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Returns a CRAM-MD5 mecanism response
pub fn cram_md5(username: &str, password: &str, encoded_challenge: &str) -> String {
// TODO manage errors
let challenge = encoded_challenge.from_base64().unwrap();
let mut hmac = Hmac::new(Md5::new(), password.as_bytes());
hmac.input(&challenge);
... | code_fim | hard | {
"lang": "rust",
"repo": "housleyjk/rust-smtp",
"path": "/src/client/authentication.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adeck/rusty-sandbox path: /book/chapters/08/vectron/src/main.rs
fn main() {
// These two statements are roughly equivalent.
/*
let mut v = Vec::new();
v.push(2);
v.push(1);
v.push(-95);
v.push(10485);
// **/
let v = vec![2, 1, -95, 10485];
println!("Just g... | code_fim | hard | {
"lang": "rust",
"repo": "adeck/rusty-sandbox",
"path": "/book/chapters/08/vectron/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>like the list doesn't have a third element."),
}
for i in &v {
println!("Element: {}", i);
}
for i in &mut v {
*i += 50;
}
println!("Modified vec: {:?}", v);
}
}<|fim_prefix|>// repo: adeck/rusty-sandbox path: /book/chapters/08/v... | code_fim | hard | {
"lang": "rust",
"repo": "adeck/rusty-sandbox",
"path": "/book/chapters/08/vectron/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Neitsch/graphql-rs path: /graphql_rs_native/src/language/ast.rs
de!(VariableDefinitionVec(Vec<VariableDefinition<'a>>));
impl<'a> fmt::Display for VariableDefinitionVec<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{}",
... | code_fim | hard | {
"lang": "rust",
"repo": "Neitsch/graphql-rs",
"path": "/graphql_rs_native/src/language/ast.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ast_node_with_location!(FragmentDefinition {
name: Name<'a>,
#[serde(rename = "variableDefinitions")]
variable_definitions: OptVariableDefinitionVec<'a>,
#[serde(rename = "typeCondition")]
type_condition: NamedType<'a>,
directives: OptDirectiveVec<'a>,
#[serde(rename = "selecti... | code_fim | hard | {
"lang": "rust",
"repo": "Neitsch/graphql-rs",
"path": "/graphql_rs_native/src/language/ast.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Neitsch/graphql-rs path: /graphql_rs_native/src/language/ast.rs
if let OptName(Some(name)) = &self.alias {
write!(f, "{}: ", name,)?;
}
write!(f, "{}{}{}", self.name, self.arguments, self.directives)?;
if let OptSelectionSet(Some(sel)) = &self.selection_set {... | code_fim | hard | {
"lang": "rust",
"repo": "Neitsch/graphql-rs",
"path": "/graphql_rs_native/src/language/ast.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>status;
#[doc = "USART Synchronization Busy"]
pub struct SYNCBUSY {
register: ::vcell::VolatileCell<u32>,
}
#[doc = "USART Synchronization Busy"]
pub mod syncbusy;
#[doc = "USART Receive Error Count"]
pub struct RXERRCNT {
register: ::vcell::VolatileCell<u8>,
}
#[doc = "USART Receive Error Count"]... | code_fim | hard | {
"lang": "rust",
"repo": "evq/atsaml11xxx",
"path": "/src/sercom0/usart/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: evq/atsaml11xxx path: /src/sercom0/usart/mod.rs
#[doc = "USART Control A"]
pub struct CTRLA {
register: ::vcell::VolatileCell<u32>,
}
#[doc = "USART Control A"]
pub mod ctrla;
#[doc = "USART Control B"]
pub struct CTRLB {
register: ::vcell::VolatileCell<u32>,
}
#[doc = "USART Control B"]... | code_fim | hard | {
"lang": "rust",
"repo": "evq/atsaml11xxx",
"path": "/src/sercom0/usart/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const K0: [[f64; 442]; 3] = [
[
0.00449282133,
0.00002247401,
0.00001705727,
0.00000653102,
0.00000646057,
0.00000535429,
0.00000333443,
0.00000252413,
0.00000251699,
0.00000239041,
0.00000166418,
0.000... | code_fim | hard | {
"lang": "rust",
"repo": "Razican/vsop87-rs",
"path": "/src/venus.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Razican/vsop87-rs path: /src/venus.rs
00472,
0.00000000509,
0.00000000543,
0.00000000392,
0.00000000429,
0.00000000421,
0.00000000419,
0.00000000387,
0.00000000392,
0.00000000376,
0.00000000404,
0.00000000393... | code_fim | hard | {
"lang": "rust",
"repo": "Razican/vsop87-rs",
"path": "/src/venus.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>4711,
4.31546172048,
1.77310868552,
0.41056182967,
5.18111845831,
0.54734126226,
1.32946380963,
3.70288653938,
4.61228467036,
3.19697256765,
1.17328568132,
6.22948567003,
1.96848855616,
0.92662471712,
... | code_fim | hard | {
"lang": "rust",
"repo": "Razican/vsop87-rs",
"path": "/src/venus.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.remain == 0 {
return Ok(None);
}
let mut identifier = [0u8; 4];
self.buffer.read_exact(&mut identifier)?;
let size = self.buffer.read_u32::<LittleEndian>()? as usize;
self.remain = self.remain.saturating_sub(size + 8);
let buffe... | code_fim | hard | {
"lang": "rust",
"repo": "anekos/image-meta",
"path": "/src/loader/riff.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anekos/image-meta path: /src/loader/riff.rs
#![allow(unused_imports)]
use std::io::{BufRead, BufReader, Cursor, Read, Seek, SeekFrom, Take};
use byteorder::{LittleEndian, ReadBytesExt};
use crate::errors::{ImageError, ImageResult};
pub struct RiffReader<T: Read + Seek> {
buffer: BufReade... | code_fim | hard | {
"lang": "rust",
"repo": "anekos/image-meta",
"path": "/src/loader/riff.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lyyyuna/durian_cake path: /rust/strsplit/src/lib.rs
#![warn(missing_debug_implementations, rust_2018_idioms)]
#[derive(Debug)]
pub struct StrSplit<'haystack, 'delimiter> {
remainder: Option<&'haystack str>,
delimiter: &'delimiter str,
}
impl<'haystack, 'delimiter> StrSplit<'haystack, '... | code_fim | medium | {
"lang": "rust",
"repo": "lyyyuna/durian_cake",
"path": "/rust/strsplit/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn tail() {
let haystack = "a b c d e ";
let letters = StrSplit::new(haystack, " ");
assert!(letters.eq(vec!["a", "b", "c", "d", "e", ""].into_iter()));
}<|fim_prefix|>// repo: lyyyuna/durian_cake path: /rust/strsplit/src/lib.rs
#![warn(missing_debug_implementations, rust_2018_idioms... | code_fim | hard | {
"lang": "rust",
"repo": "lyyyuna/durian_cake",
"path": "/rust/strsplit/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let haystack = "a b c d e f";
let letters = StrSplit::new(haystack, " ");
assert!(letters.eq(vec!["a", "b", "c", "d", "e", "f"].into_iter()));
}
#[test]
fn tail() {
let haystack = "a b c d e ";
let letters = StrSplit::new(haystack, " ");
assert!(letters.eq(vec!["a", "b", "c", "d... | code_fim | hard | {
"lang": "rust",
"repo": "lyyyuna/durian_cake",
"path": "/rust/strsplit/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn compute_letter_freq(input: &str) -> (usize, usize) {
let mut frequencies = HashMap::new();
for c in input.chars() {
frequencies.entry(c).and_modify(|c| *c += 1).or_insert(1);
}
let (mut twos, mut threes) = (0, 0);
for (_, count) in frequencies {
if count == 3 {
... | code_fim | hard | {
"lang": "rust",
"repo": "cbrewster/advent_of_code_2018",
"path": "/day02/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cbrewster/advent_of_code_2018 path: /day02/src/main.rs
use std::collections::HashMap;
fn main() {
let input = include_str!("../input.txt");
let checksum = compute_checksum(&input);
println!("The checksum is {}.", checksum);
let common_letters = find_common_letters(&input);
<... | code_fim | hard | {
"lang": "rust",
"repo": "cbrewster/advent_of_code_2018",
"path": "/day02/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (index, id) in ids.iter().enumerate() {
for other_id in &ids[index + 1..] {
let mut difference = 0;
let mut different_char = '\0';
for (char1, char2) in id.chars().zip(other_id.chars()) {
if char1 != char2 {
difference... | code_fim | hard | {
"lang": "rust",
"repo": "cbrewster/advent_of_code_2018",
"path": "/day02/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[lang = "panic_fmt"]
fn panic_fmt() -> ! {
loop {}
}<|fim_prefix|>// repo: ekoeppen/armstrong path: /src/lang_items.rs
/*!
Lang items, required by the compiler
*/
extern crate core;
<|fim_middle|>#[lang="stack_exhausted"]
pub extern "C" fn rust_stack_exhausted() -> !{
loop {}
}
#[lang="eh_person... | code_fim | medium | {
"lang": "rust",
"repo": "ekoeppen/armstrong",
"path": "/src/lang_items.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ekoeppen/armstrong path: /src/lang_items.rs
/*!
Lang items, required by the compiler
*/
extern crate core;
<|fim_suffix|>#[lang="eh_personality"]
pub fn eh_personality() {}
#[lang = "panic_fmt"]
fn panic_fmt() -> ! {
loop {}
}<|fim_middle|>#[lang="stack_exhausted"]
pub extern "C" fn rust... | code_fim | medium | {
"lang": "rust",
"repo": "ekoeppen/armstrong",
"path": "/src/lang_items.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kiwiscott/aoc-2019 path: /src/day6.rs
use aoc_runner_derive::{aoc, aoc_generator};
use std::collections::{HashMap, HashSet};
#[aoc_generator(day6)]
fn parse_input(input: &str) -> Orbits {
let mut res = Orbits::new();
for line in input.lines() {
let v: Vec<&str> = line.splitn(2,... | code_fim | hard | {
"lang": "rust",
"repo": "kiwiscott/aoc-2019",
"path": "/src/day6.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> visited.insert(from.to_string());
self.find_neignbours(from)
.iter()
.filter(|n| !visited.contains(*n))
.map(|n| self.path(n, destination, &mut visited.clone()))
.max()
.unwrap_or(0)
}
fn find_neignbours(&self, from: &str... | code_fim | hard | {
"lang": "rust",
"repo": "kiwiscott/aoc-2019",
"path": "/src/day6.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if from == destination {
return visited.len() as i32;
}
visited.insert(from.to_string());
self.find_neignbours(from)
.iter()
.filter(|n| !visited.contains(*n))
.map(|n| self.path(n, destination, &mut visited.clone()))
... | code_fim | hard | {
"lang": "rust",
"repo": "kiwiscott/aoc-2019",
"path": "/src/day6.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theanirudhvyas/boron path: /src/router.rs
use middleware::Middleware;
use request::Request;
use response::Response;
use matcher::Matcher;
use hyper::method::Method;
struct Route {
method: Method,
path: Matcher,
action: Box<Middleware>
}
pub trait HttpMethods {
fn new_route<T: M... | code_fim | hard | {
"lang": "rust",
"repo": "theanirudhvyas/boron",
"path": "/src/router.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn put<T: Middleware>(&mut self, path: &str, action: T) {
self.new_route(Method::Put, path, action);
}
fn delete<T: Middleware>(&mut self, path: &str, action: T) {
self.new_route(Method::Delete, path, action);
}
}
pub struct Router {
base: String,
routes: Vec<Rout... | code_fim | hard | {
"lang": "rust",
"repo": "theanirudhvyas/boron",
"path": "/src/router.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.new_route(Method::Post, path, action);
}
fn put<T: Middleware>(&mut self, path: &str, action: T) {
self.new_route(Method::Put, path, action);
}
fn delete<T: Middleware>(&mut self, path: &str, action: T) {
self.new_route(Method::Delete, path, action);
}
}
... | code_fim | medium | {
"lang": "rust",
"repo": "theanirudhvyas/boron",
"path": "/src/router.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Copy)]
#[repr(C)]
pub struct Color {
pub red: u8,
pub green: u8,
pub blue: u8,
}
impl Color {
pub fn clear(&mut self) {
self.red = 0;
self.green = 0;
self.blue = 0;
}
}
impl Apa106 {
pub fn new(channel: RmtChannel, pin: OutputPin, le... | code_fim | hard | {
"lang": "rust",
"repo": "syntacticsugarglider/esp32-apa106-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: syntacticsugarglider/esp32-apa106-rs path: /src/lib.rs
use std::{
convert::TryFrom,
fmt::Debug,
mem::size_of,
ops::{Index, IndexMut},
slice::{self, Iter, IterMut, SliceIndex},
};
use thiserror::Error;
use esp_idf_sys::{
c_types::c_void, esp, gpio_num_t, rmt_carrier_level... | code_fim | hard | {
"lang": "rust",
"repo": "syntacticsugarglider/esp32-apa106-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eruca/rustbyexample path: /permutation_排列/src/main.rs
fn main() {
let result :Vec<String> = (123..329).filter_map(help).map(|(a,b,c)| format!("{} {} {}\n", a, b, c)).collect();
print!("{}", result.concat());
}
fn help(a: i32) -> Option<(i32,i32,i32)>{
let b = 2 * a;
let c = 3 * a;
let (su... | code_fim | medium | {
"lang": "rust",
"repo": "eruca/rustbyexample",
"path": "/permutation_排列/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let b = 2 * a;
let c = 3 * a;
let (suma,muta) = split(a);
let (sumb, mutb) = split(b);
let (sumc, mutc) = split(c);
if suma + sumb +sumc == 45 && muta * mutb*mutc == 362880 {
return Some((a,b,c));
}
None
}
fn split(num :i32) -> (i32, i32) {
let a = num / 100;
let b = num /10 % 10;
let c =... | code_fim | medium | {
"lang": "rust",
"repo": "eruca/rustbyexample",
"path": "/permutation_排列/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn split(num :i32) -> (i32, i32) {
let a = num / 100;
let b = num /10 % 10;
let c = num % 10;
let sum = a + b + c;
let mul = a*b*c;
(sum, mul)
}<|fim_prefix|>// repo: eruca/rustbyexample path: /permutation_排列/src/main.rs
fn main() {
let result :Vec<String> = (123..329).filter_map(help).map(|(a,b... | code_fim | medium | {
"lang": "rust",
"repo": "eruca/rustbyexample",
"path": "/permutation_排列/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akamit91/rustkpi path: /rust/kmod-e1000/src/bridge.rs
use kernel;
use kernel::sys::raw::*;
use kernel::prelude::v1::*;
use kernel::ptr::NonNull;
use kernel::sys::kernel_sys::caddr_t;
use sys::iflib::iflib_ctx;
use sys::iflib::if_softc_ctx;
use sys::iflib::ifmedia;
use sys::iflib::iflib_get_dev... | code_fim | hard | {
"lang": "rust",
"repo": "akamit91/rustkpi",
"path": "/rust/kmod-e1000/src/bridge.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn detach(&mut self) -> Result<(), String>;
fn queues_free(&mut self);
fn release(&mut self);
}
pub trait IfTxRx {
fn em_txd_encap(&mut self, pi: &mut IfPacketInfo) -> i32;
fn em_txd_flush(&mut self, txqid: u16, pidx: u16);
fn em_txd_credits_update(&mut self, txqid: u16, clear: bo... | code_fim | hard | {
"lang": "rust",
"repo": "akamit91/rustkpi",
"path": "/rust/kmod-e1000/src/bridge.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[repr(C)]
pub struct nsIFeedResultServiceVTable {
pub __base: nsISupportsVTable,
/* attribute boolean forcePreviewPage; */
pub get_forcePreviewPage: unsafe extern "C" fn (this: *const nsIFeedResultService, aForcePreviewPage: *mut bool) -> nsresult,
pub set_forcePreviewPage: unsafe extern... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/rt/nsIFeedResultService.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /rt/nsIFeedResultService.rs
//
// DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIFeedResultService.idl
//
#[repr(C)]
pub struct nsIFeedResultService {
vtable: *const nsIFeedResultServiceVTable,
/// This field is a phantomdata to ensure th... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/rt/nsIFeedResultService.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Maix0/pixel_engine path: /examples/fps_pixel_old/src/bin/map-edit/main.rs
#![allow(dead_code)]
extern crate pixel_engine as engine;
extern crate ron;
extern crate serde;
#[path = "../../maps.rs"]
mod maps;
use engine::inputs::Keycodes as Keycode;
use engine::traits::*;
fn sprite_frame(game: &mu... | code_fim | hard | {
"lang": "rust",
"repo": "Maix0/pixel_engine",
"path": "/examples/fps_pixel_old/src/bin/map-edit/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // HANDLE SPRITE LIST
/* 267,306,328,289 */
let mut selected_tile = c_world.tiles.values().nth(selected_tile_index as usize);
let mut d_offset = 0;
for (chr, spr) in &c_world.tiles {
match selected_tile.clone() {
Some(_) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "Maix0/pixel_engine",
"path": "/examples/fps_pixel_old/src/bin/map-edit/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chibby0ne/cryptopals path: /set1/src/challenge6/mod.rs
/*
Break repeating-key XOR
It is officially on, now.
This challenge isn't conceptually hard, but it involves actual error-prone coding. The other
challenges in this set are there to bring you up to speed. This one is there to qualify you.... | code_fim | hard | {
"lang": "rust",
"repo": "chibby0ne/cryptopals",
"path": "/set1/src/challenge6/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_hamming_distance() {
let s = "this is a test";
let t = "wokka wokka!!!";
let expected_output: usize = 37;
assert_eq!(hamming_distance(s, t), expected_output);
}
#[test]
fn test_find_keysize() {
let input = "src/challenge6/6.txt";... | code_fim | hard | {
"lang": "rust",
"repo": "chibby0ne/cryptopals",
"path": "/set1/src/challenge6/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.