text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let mut send_stream = TcpStream::connect(ADDRESS).unwrap();
let mut recv_stream = TcpStream::connect(ADDRESS).unwrap();
let mut bin = String::new();
let args: Vec<u8> = std::io::stdin()
.lock()
.split(b'\n')
.filter_map(Result::ok)
.map(|mut s| {
... | code_fim | medium | {
"lang": "rust",
"repo": "sigmaSd/Gbar",
"path": "/gbar_client/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sigmaSd/Gbar path: /gbar_client/src/main.rs
use std::io::prelude::*;
use std::net::TcpStream;
const ADDRESS: &str = "127.0.0.1:38451";
<|fim_suffix|> send_stream.write_all(&args).unwrap();
send_stream.flush().unwrap();
drop(send_stream);
recv_stream.read_to_string(&mut bin).unwr... | code_fim | hard | {
"lang": "rust",
"repo": "sigmaSd/Gbar",
"path": "/gbar_client/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonayerdi/aoc2018 path: /src/bin/day1.rs
use std::fs::File;
use std::io::{self, Read};
use std::path::PathBuf;
<|fim_suffix|> let mut input = String::new();
File::open(PathBuf::from("data").join("day1.txt"))?.read_to_string(&mut input)?;
let sum: i64 = input
.lines()
... | code_fim | easy | {
"lang": "rust",
"repo": "jonayerdi/aoc2018",
"path": "/src/bin/day1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut input = String::new();
File::open(PathBuf::from("data").join("day1.txt"))?.read_to_string(&mut input)?;
let sum: i64 = input
.lines()
.map(|e| e.trim().parse::<i64>().unwrap())
.sum();
println!("{}", sum);
Ok(())
}<|fim_prefix|>// repo: jonayerdi/aoc2018... | code_fim | easy | {
"lang": "rust",
"repo": "jonayerdi/aoc2018",
"path": "/src/bin/day1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jin-WW/mandelbrot path: /src/main.rs
extern crate num;
extern crate image;
use num::Complex;
use image::ColorType;
use image::png::PNGEncoder;
use std::fs::File;
fn main() {
println!("Rendering Mandelbrot");
let bounds = (400, 300);
let upper_left = Complex {re: -1.2, im: 0.3};
... | code_fim | hard | {
"lang": "rust",
"repo": "Jin-WW/mandelbrot",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_pixel_to_point() {
assert_eq!(
pixel_to_point((100, 100), (25, 75), Complex {re: -1.0 as f64, im: 1.0 as f64}, Complex {re: 1.0, im: -1.0}),
Complex {re: -0.5, im: -0.5}
);
}
fn render(pixels: &mut [u8],
bounds: (usize, usize),
upper_left: Complex<f64>,
lower_right: Complex<f... | code_fim | hard | {
"lang": "rust",
"repo": "Jin-WW/mandelbrot",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: meox/AOC2020 path: /day08-rust/src/main.rs
use std::collections::HashSet;
use std::convert::TryFrom;
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
#[derive(Debug, Clone)]
enum Op {
ACC(i32),
JMP(i32),
NOP(i32),
INVALID(String),
}
#[derive(Debug)]
struct ... | code_fim | hard | {
"lang": "rust",
"repo": "meox/AOC2020",
"path": "/day08-rust/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn execute(ops: &Vec<Op>, mut ctx: Ctx) -> (Ctx, bool) {
let mut visited: HashSet<usize> = HashSet::new();
loop {
if ctx.ip >= ops.len() {
break
}
let opcode = ops[ctx.ip].clone();
if visited.get(&ctx.ip).is_some() {
return (ctx, false);
... | code_fim | hard | {
"lang": "rust",
"repo": "meox/AOC2020",
"path": "/day08-rust/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let instrs = load_fromfile("data/input.txt");
let bin = compile(instrs).unwrap();
//println!("compiled = {:?}", bin);
let r = execute(&bin, Ctx{ acc: 0, ip: 0 });
println!("VM: {:?}", r);
// second part
// 1. change all jmp in nop (step by step)
let len = bin.len();
f... | code_fim | hard | {
"lang": "rust",
"repo": "meox/AOC2020",
"path": "/day08-rust/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_test_fn(|client, _conn| {
let get_response = client.get("/api/status/").dispatch();
assert_eq!(get_response.status(), Status::Ok);
let response_body = get_response.into_string().unwrap();
assert_eq!(
response_body,
... | code_fim | hard | {
"lang": "rust",
"repo": "chorddown/chordr",
"path": "/srvchord/src/routes/status.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let response_body = get_response.into_string().unwrap();
assert_eq!(
response_body,
json_format::<JsonTemplateValue>(
r#"{"version":"$","running":true}"#,
vec![env!("CARGO_PKG_VERSION").into(),],
... | code_fim | hard | {
"lang": "rust",
"repo": "chorddown/chordr",
"path": "/srvchord/src/routes/status.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chorddown/chordr path: /srvchord/src/routes/status.rs
use rocket::get;
use rocket::serde::json::Json;
pub fn get_routes() -> Vec<rocket::Route> {
routes![crate::routes::status::index,]
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Status {
version: &'static str,
runn... | code_fim | medium | {
"lang": "rust",
"repo": "chorddown/chordr",
"path": "/srvchord/src/routes/status.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ProcessingState {
Normal, // Executing instructions
Group2Exception, // TRAP(V), CHK, ZeroDivide
Group1Exception, // Trace, Interrupt, IllegalInstruction, PrivilegeViolation
Group0Exception, // AddressError, BusError, E... | code_fim | hard | {
"lang": "rust",
"repo": "marhel/r68k",
"path": "/emu/src/cpu/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marhel/r68k path: /emu/src/cpu/mod.rs
b() {
let mut cpu = TestCore::new_mem(0xba, &[0x00, 0x0B, 1u8,0u8, 0u8,0u8,0u8,128u8]);
cpu.instruction_set = ops::fake::instruction_set();
cpu.execute1();
assert_eq!(0x0000, cpu.dar[0]);
assert_eq!(0xbcde, cpu.dar[1])... | code_fim | hard | {
"lang": "rust",
"repo": "marhel/r68k",
"path": "/emu/src/cpu/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marhel/r68k path: /emu/src/cpu/mod.rs
f self.s_flag == SFLAG_SET {
self.inactive_usp = self.dar[15];
self.dar[15] = self.inactive_ssp;
} else {
self.inactive_ssp = self.dar[15];
self.dar[15] = self.inactive_usp;
... | code_fim | hard | {
"lang": "rust",
"repo": "marhel/r68k",
"path": "/emu/src/cpu/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alvatar/pseudokafka path: /src/ser.rs
use byteorder::{NetworkEndian, WriteBytesExt};
use std::io::{Cursor, Write};
use std::mem;
use crate::error::*;
use crate::messages::*;
macro_rules! encode_with {
{
$cursor:ident:
$($name:expr),*
} => {
$(
$name... | code_fim | hard | {
"lang": "rust",
"repo": "alvatar/pseudokafka",
"path": "/src/ser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let req = &ApiVersionsRequest {
header: RequestHeader {
api_key: ApiKey::Produce,
api_version: 0,
correlation_id: 0,
client_id: None,
},
};
let msg = ApiVersionsResponse::new(req);
asser... | code_fim | hard | {
"lang": "rust",
"repo": "alvatar/pseudokafka",
"path": "/src/ser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let offset = if self.size > 0.0 {
Vector3::new(
rng.gen_range(-self.size, self.size),
rng.gen_range(-self.size, self.size),
rng.gen_range(-self.size, self.size)
)
} else {
Vector3::zero()
};
... | code_fim | medium | {
"lang": "rust",
"repo": "inda18plusplus/cnol-ray-tracer",
"path": "/src/light/point_light.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: inda18plusplus/cnol-ray-tracer path: /src/light/point_light.rs
use rand;
use rand::Rng;
use vector::Vector3;
use color::Color;
<|fim_suffix|>
impl PointLight {
pub fn sample_point(&self) -> Vector3 {
let mut rng = rand::thread_rng();
let offset = if self.size > 0.0 {
... | code_fim | medium | {
"lang": "rust",
"repo": "inda18plusplus/cnol-ray-tracer",
"path": "/src/light/point_light.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HaronK/aoc2019 path: /task08_2/src/main.rs
use anyhow::{ensure, Result};
use std::fs::File;
use std::io::prelude::*;
fn main() -> Result<()> {
let mut content = String::new();
let mut file = File::open("input.txt")?;
file.read_to_string(&mut content)?;
let result = process_ima... | code_fim | hard | {
"lang": "rust",
"repo": "HaronK/aoc2019",
"path": "/task08_2/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for p in 0..layer_size {
// println!(" rp: {}, lp: {}", result[p], layer_data[p]);
if result[p] == 2 && layer_data[p] != 2 {
result[p] = layer_data[p];
// println!(" change: {}", result[p]);
remaining_pixels -= 1;
... | code_fim | hard | {
"lang": "rust",
"repo": "HaronK/aoc2019",
"path": "/task08_2/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let output_count = usize::try_from(witness.challenge_count).or(Err(Error::Encoding))? + 1;
// 2 + challenge_count - 1 * Since this checker already voted
for i in 2..output_count {
let (task_output, task_output_type_args) = load_entities! {
TaskCell: CellOrigin(i, Source::... | code_fim | hard | {
"lang": "rust",
"repo": "LycrusHamster/axon",
"path": "/axon-ckb-contracts/contracts/code-cell/src/checker_publish_challenge.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LycrusHamster/axon path: /axon-ckb-contracts/contracts/code-cell/src/checker_publish_challenge.rs
use crate::{cell::*, common::*, error::Error};
use ckb_std::ckb_constants::Source;
use core::convert::TryFrom;
use common_raw::{
cell::{
checker_info::{CheckerInfoCell, CheckerInfoCellT... | code_fim | hard | {
"lang": "rust",
"repo": "LycrusHamster/axon",
"path": "/axon-ckb-contracts/contracts/code-cell/src/checker_publish_challenge.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // data types
let guess: u32 = "42".parse().expect("Not a number!");
let x = 2.0;
let y: f32 = 3.0;
let tup: (i32, f64, u8) = (500, 6.4, 1);
// Arrays
let a = [1, 2, 3, 4, 5];
let first = a[0];
let second = a [1];
}<|fim_prefix|>// repo: JasonShin/rust-playground p... | code_fim | medium | {
"lang": "rust",
"repo": "JasonShin/rust-playground",
"path": "/variables/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JasonShin/rust-playground path: /variables/src/main.rs
fn main() {
let mut x = 5;
println!("Hello, world! {}", x);
x = 6;
println!("The value of x is {}", x);
const MAX_POINTS: u32 = 100_000;
let x = 5;
let x = x + 1;
let x = x * 2;
println!("The value of... | code_fim | medium | {
"lang": "rust",
"repo": "JasonShin/rust-playground",
"path": "/variables/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// pub async fn get_cookie(req: HttpRequest) -> impl Responder {
// // 读取cookie值
// let a = req.headers().get("cookie").unwrap();
// let c = Cookie::parse(a.to_str().unwrap()).unwrap();
// format!("cookie {} = {}", c.name(), c.value())
// }
// // 设置和访问cookie
// pub async fn set_cookie() -... | code_fim | hard | {
"lang": "rust",
"repo": "daviscai/crab",
"path": "/src/controllers/app/home.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 解析字符串到Person对象。
let p: Person = serde_json::from_str(data).unwrap();
debug!("Please call {} at the number {}", p.name, p.phones[0]);
// Person对象转为JSON字符串.
let serialized = serde_json::to_string(&p).unwrap();
debug!("serialized = {}", serialized);
}
// // 基于 session 会话的数据存... | code_fim | hard | {
"lang": "rust",
"repo": "daviscai/crab",
"path": "/src/controllers/app/home.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daviscai/crab path: /src/controllers/app/home.rs
use actix_web::{
web,
Responder,
//HttpRequest
//Error,
//HttpResponse
};
// use crate::AppToolkit;
use log::*;
// use actix_session::{Session};
// use actix_http::cookie::Cookie;
use crate::core::app::{AppToolkit};
// use ... | code_fim | hard | {
"lang": "rust",
"repo": "daviscai/crab",
"path": "/src/controllers/app/home.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wgwoods/atsamd path: /pac/atsamd51g19a/src/dmac/swtrigctrl.rs
f.w
}
}
#[doc = "Reader of field `SWTRIG16`"]
pub type SWTRIG16_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `SWTRIG16`"]
pub struct SWTRIG16_W<'a> {
w: &'a mut W,
}
impl<'a> SWTRIG16_W<'a> {
#[doc = r"Sets the... | code_fim | hard | {
"lang": "rust",
"repo": "wgwoods/atsamd",
"path": "/pac/atsamd51g19a/src/dmac/swtrigctrl.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wgwoods/atsamd path: /pac/atsamd51g19a/src/dmac/swtrigctrl.rs
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 21)) | (((value as u32) & 0x01) << 21);
self.w
}
}
#[do... | code_fim | hard | {
"lang": "rust",
"repo": "wgwoods/atsamd",
"path": "/pac/atsamd51g19a/src/dmac/swtrigctrl.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct RemoveProcess {
id : u64
}
pub struct StartProcess {}
pub struct CreateProcess {
pub parent : u64,
pub process_message : ProcessBox
}
pub struct RootProcess {
executor : ExecutorRef,
}
impl RootProcess {
/*pub fn new(executor : ExecutorRef) -> ProcessRef {
unsa... | code_fim | hard | {
"lang": "rust",
"repo": "nshyrei/rustos",
"path": "/multiprocess/src/process/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nshyrei/rustos path: /multiprocess/src/process/mod.rs
use crate::executor::Executor;
use crate::executor::ExecutorRef;
use alloc::rc::Rc;
use core::cell;
use core::ops::Deref;
use core::clone::Clone;
use core::any::Any;
use core::default::Default;
use alloc::boxed::Box;
pub type Message = Box... | code_fim | hard | {
"lang": "rust",
"repo": "nshyrei/rustos",
"path": "/multiprocess/src/process/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aldanor/rust-uttt path: /src/main.rs
use std::time::SystemTime;
use once_cell::sync::Lazy;
fn main() {
benchmark("movegen", || {
println!("{}", move_gen(7));
});
}
fn benchmark<F>(name: &str, mut func: F)
where
F: FnMut() -> (),
{
println!(">>> Starting {}...", name);
... | code_fim | hard | {
"lang": "rust",
"repo": "aldanor/rust-uttt",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe { *self.meta_field.get_unchecked_mut(p) = meta_field };
}
pub fn make_move(&mut self, pos: Pos) {
let square = self.get_mut(self.turn, pos.field);
*square |= pos.square;
let square = *square;
if is_won(square) {
self.set_field_status(pos.... | code_fim | hard | {
"lang": "rust",
"repo": "aldanor/rust-uttt",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pabloalonsos/matasano-crypto-challenges path: /src/set_1/detect_aes_ecb.rs
use std::error::Error;
use std::io::prelude::*;
use std::fs::File;
use std::path::Path;
use std::collections::HashMap;
use super::super::utils::crypto_data::CryptoData;
pub fn detect_aes_ecb(data_file: &str) -> CryptoDa... | code_fim | hard | {
"lang": "rust",
"repo": "pabloalonsos/matasano-crypto-challenges",
"path": "/src/set_1/detect_aes_ecb.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let score = cypher_map.values().fold(0, |acc, &val| acc + val );
if score > current_score {
(cypher, score)
} else {
acc
}
});
CryptoData::new_from_str(cypher_text)
}<|fim_prefix|>// repo: pabloalonsos/matasano-crypto-challenges path: /s... | code_fim | hard | {
"lang": "rust",
"repo": "pabloalonsos/matasano-crypto-challenges",
"path": "/src/set_1/detect_aes_ecb.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Option 2
//let current_val = cypher_map.remove(chunk).unwrap();
//cypher_map.insert(chunk, current_val + 1);
// Option 3
// if let Some(count) = cypher_map.get_mut(chunk) {
// *count += 1;
... | code_fim | hard | {
"lang": "rust",
"repo": "pabloalonsos/matasano-crypto-challenges",
"path": "/src/set_1/detect_aes_ecb.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: k0pernicus/orbclient path: /examples/black_window.rs
extern crate orbclient;
use orbclient::{Color, Window};
use std::thread;
fn main() {
let width = 600;
let height = 600;
<|fim_suffix|> let border_limit = (width / 2) as i32;
for i in 0..border_limit {
window.set_bo... | code_fim | hard | {
"lang": "rust",
"repo": "k0pernicus/orbclient",
"path": "/examples/black_window.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..border_limit {
window.set_border_top(i, Color::rgb(0,0,0), 1);
window.set_border_left(i, Color::rgb(0,0,0), 1);
window.set_border_bottom(i, Color::rgb(0,0,0), 1);
window.set_border_right(i, Color::rgb(0,0,0), 1);
window.sync();
thread::sleep_... | code_fim | hard | {
"lang": "rust",
"repo": "k0pernicus/orbclient",
"path": "/examples/black_window.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Luis-Hebendanz/vmsh path: /src/tracer/wrap_syscall.rs
use crate::tracer::Tracer;
use kvm_bindings as kvmb;
use log::{debug, trace, warn};
use nix::unistd::getpgid;
use nix::unistd::Pid;
use nix::{
errno::Errno,
sys::wait::{waitpid, WaitStatus},
};
use nix::{sys::signal::Signal, unistd::g... | code_fim | hard | {
"lang": "rust",
"repo": "Luis-Hebendanz/vmsh",
"path": "/src/tracer/wrap_syscall.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn process_status(&mut self, status: WaitStatus) -> Result<Option<MmioRw>> {
match status {
WaitStatus::PtraceSyscall(pid) => {
return self.stopped(pid);
}
WaitStatus::Exited(tid, status) => {
warn!("thread {} exited with: {}"... | code_fim | hard | {
"lang": "rust",
"repo": "Luis-Hebendanz/vmsh",
"path": "/src/tracer/wrap_syscall.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_process_group(pid: Pid) -> Result<Pid> {
let process_group = try_with!(getpgid(Some(pid)), "getppid failed");
if getpgrp() == process_group {
bail!("vmsh and hypervisor are in same process group. Are they sharing a terminal? This is not supported at the moment.")
}
Ok(proce... | code_fim | hard | {
"lang": "rust",
"repo": "Luis-Hebendanz/vmsh",
"path": "/src/tracer/wrap_syscall.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn mark_update(&mut self, renderer: &Rc<RefCell<dyn Renderer>>) -> usize {
self.dirty_renderer.push(Rc::downgrade(renderer));
self.dirty_renderer.len()
}
pub fn get_updatable(&mut self) -> Vec<Rc<RefCell<dyn Renderer>>> {
let dirty_renderer = std::mem::replace(&mut... | code_fim | medium | {
"lang": "rust",
"repo": "yyjhao/rust-react",
"path": "/src/scope/updater.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yyjhao/rust-react path: /src/scope/updater.rs
use std::rc::{Rc, Weak};
use std::cell::RefCell;
use crate::scope::renderer::Renderer;
use crate::scope::scope::Scope;
use crate::scope::effect::EffectStoreT;
pub struct Updater {
dirty_renderer: Vec<Weak<RefCell<dyn Renderer>>>,
}
<|fim_suffix... | code_fim | hard | {
"lang": "rust",
"repo": "yyjhao/rust-react",
"path": "/src/scope/updater.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tupshin/ProjectEuler path: /Problem7.rs
fn main()
{
let (mut n, mut i, mut count, mut c, mut a) = (0i32,3i32,0i32,0i32,1i32);//int n, i = 3, count, c;
<|fim_suffix|> while count <= n //( count = 2 ; count <= n ; )
{
c = 2i32;
while c <= i // OR for c in range(c, i -1) ( c... | code_fim | medium | {
"lang": "rust",
"repo": "tupshin/ProjectEuler",
"path": "/Problem7.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if n >= 1
{
println!("First {} prime numbers are :\n",n);
println!("1: 2\n");
}
while count <= n //( count = 2 ; count <= n ; )
{
c = 2i32;
while c <= i // OR for c in range(c, i -1) ( c = 2 ; c <= i - 1 ; c++ )
{
if i%c == 0 {
brea... | code_fim | medium | {
"lang": "rust",
"repo": "tupshin/ProjectEuler",
"path": "/Problem7.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yuripourre-forks/antlr4rust path: /src/rule_context.rs
//use tree::RuleNode;
use std::any::Any;
use std::borrow::BorrowMut;
use std::cell::{Cell, RefCell};
use std::rc::{Rc, Weak};
use crate::atn::INVALID_ALT;
use crate::parser_rule_context::{BaseParserRuleContext, ParserRuleContext, ParserRul... | code_fim | medium | {
"lang": "rust",
"repo": "yuripourre-forks/antlr4rust",
"path": "/src/rule_context.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.invoking_state.set(t)
}
fn get_parent_ctx(&self) -> Option<Rc<dyn ParserRuleContext>> {
self.parent_ctx.borrow().as_ref().map(Weak::upgrade).flatten()
}
fn peek_parent(&self) -> Option<ParserRuleContextType> {
self.parent_ctx.borrow().as_ref().map(Weak::upgra... | code_fim | hard | {
"lang": "rust",
"repo": "yuripourre-forks/antlr4rust",
"path": "/src/rule_context.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Or insert new one
} else {
let mut conn = Connection::new(
self.config,
self.local_address.unwrap(),
addr,
R::new(self.config),
M::new(self.config),
);
conn.set_id(id);
... | code_fim | hard | {
"lang": "rust",
"repo": "tom-leys/cobalt-rs",
"path": "/src/server.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Overrides the server's current configuration.
pub fn set_config(&mut self, config: Config) {
self.config = config;
self.ticker.set_config(config);
self.stats_collector.set_config(config);
for conn in self.connections.values_mut() {
conn.set_config(c... | code_fim | hard | {
"lang": "rust",
"repo": "tom-leys/cobalt-rs",
"path": "/src/server.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tom-leys/cobalt-rs path: /src/server.rs
// Copyright (c) 2015-2017 Ivo Wetzel
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This fi... | code_fim | hard | {
"lang": "rust",
"repo": "tom-leys/cobalt-rs",
"path": "/src/server.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: g-s-k/trx path: /src/bin/trx/main.rs
use std::fs::File;
use std::io::{stdout, BufWriter, Result as IOResult, Write};
use std::path::PathBuf;
use glob::{Pattern, PatternError};
use structopt::StructOpt;
use trx::*;
#[derive(Debug, StructOpt)]
#[structopt(name = "trx", about = "A tree command t... | code_fim | hard | {
"lang": "rust",
"repo": "g-s-k/trx",
"path": "/src/bin/trx/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let positive = match pattern_ify(cfg.keep_pattern) {
Ok(v) => v,
Err(e) => {
eprintln!("ERROR: {}", e);
std::process::exit(1);
}
};
let negative = match pattern_ify(cfg.ignore_pattern) {
Ok(v) => v,
Err(e) => {
eprintl... | code_fim | hard | {
"lang": "rust",
"repo": "g-s-k/trx",
"path": "/src/bin/trx/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() -> IOResult<()> {
let cfg = Config::from_args();
let current_dir = PathBuf::from(".");
let dir = cfg.dir.as_ref().unwrap_or(¤t_dir);
let positive = match pattern_ify(cfg.keep_pattern) {
Ok(v) => v,
Err(e) => {
eprintln!("ERROR: {}", e);
... | code_fim | hard | {
"lang": "rust",
"repo": "g-s-k/trx",
"path": "/src/bin/trx/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if extension != expected_extension {
bail!("Invalid extension: {}", path.display());
}
ids.insert(Id::new(id));
}
ids
}
#[throws]
fn check_dir(path: &Path) {
if !(path.exists() && path.is_dir()) {
bail!("Library directory does not exist: `{}`", path.dis... | code_fim | hard | {
"lang": "rust",
"repo": "vrkansagara/dotfiles",
"path": "/pkg/music/src/library.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vrkansagara/dotfiles path: /pkg/music/src/library.rs
use crate::common::*;
pub(crate) struct Library {
base: PathBuf,
mp3: PathBuf,
new: PathBuf,
}
impl Library {
#[throws]
pub(crate) fn new() -> Self {
let base = dirs::home_dir()
.ok_or_else(|| anyhow!("Failed to find ho... | code_fim | hard | {
"lang": "rust",
"repo": "vrkansagara/dotfiles",
"path": "/pkg/music/src/library.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// An object.
pub trait Object {
/// Render the object.
fn render(&self, &mut Frame) -> Result<()>;
}<|fim_prefix|>// repo: bodoni/interface path: /src/lib/interface.rs
extern crate curve;
extern crate font;
#[macro_use]
extern crate glium;
#[macro_use]
mod outcome;
mod context;
mod display;
... | code_fim | medium | {
"lang": "rust",
"repo": "bodoni/interface",
"path": "/src/lib/interface.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bodoni/interface path: /src/lib/interface.rs
extern crate curve;
extern crate font;
#[macro_use]
extern crate glium;
#[macro_use]
mod outcome;
<|fim_suffix|>pub use display::Display;
pub use frame::{Frame, Indices, Vertices};
pub use glyph::Glyph;
pub use outcome::{Error, Result};
pub use sce... | code_fim | medium | {
"lang": "rust",
"repo": "bodoni/interface",
"path": "/src/lib/interface.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let out_file_path = out_path.join(&in_file_path);
let file_path = src_path.join(&in_file_path);
if !file_path.is_file() {
let full_path = src_path.join(file);
let full_path = full_path.to_str().unwrap();
return Err(EvalError::NotFile(full_path.to_string()));
}
... | code_fim | hard | {
"lang": "rust",
"repo": "stanipintjuk/foil",
"path": "/src/compiler/evaluator/evaluators/path_evaluator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stanipintjuk/foil path: /src/compiler/evaluator/evaluators/path_evaluator.rs
// TODO: Maybe this file should be moved to another module?
use compiler::evaluator::EvalResult;
use compiler::errors::EvalError;
use compiler::models::Output;
use compiler::{evaluate_file, write_to_file, copy_file};
us... | code_fim | hard | {
"lang": "rust",
"repo": "stanipintjuk/foil",
"path": "/src/compiler/evaluator/evaluators/path_evaluator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mdsteele/rust-ico path: /src/image.rs
ch png_reader.info().color_type {
png::ColorType::Rgba => buffer,
png::ColorType::Rgb => {
let num_pixels = buffer.len() / 3;
let mut rgba = Vec::with_capacity(num_pixels * 4);
for i in ... | code_fim | hard | {
"lang": "rust",
"repo": "mdsteele/rust-ico",
"path": "/src/image.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mdsteele/rust-ico path: /src/image.rs
png_reader,
Err(error) => invalid_data!("Malformed PNG data: {}", error),
};
IconImage::validate_png_info(png_reader.info())?;
Ok(png_reader)
}
fn validate_png_info(info: &png::Info) -> io::Result<()> {
if... | code_fim | hard | {
"lang": "rust",
"repo": "mdsteele/rust-ico",
"path": "/src/image.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Write the mask data:
for row in 0..height {
let mut start = (4 * (height - row - 1) * width) as usize;
let mut col = 0;
for _ in 0..mask_row_data_size {
let mut byte = 0;
for bit in 0..8 {
if rgba[st... | code_fim | hard | {
"lang": "rust",
"repo": "mdsteele/rust-ico",
"path": "/src/image.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kiraarghy/AOC_2020 path: /day1P2.rs
fn main() {
let x = vec![
1749, 1897, 881, 1736, 1161, 1720, 1676, 305, 264, 1904, 1880, 1173, 483, 1978, 1428, 1635,
1386, 1858, 1602, 1916, 1906, 1212, 1730, 1777, 1698, 1845, 1812, 1922, 1729, 1803, 1761,
1901, 1748, 1188, 1964, ... | code_fim | hard | {
"lang": "rust",
"repo": "kiraarghy/AOC_2020",
"path": "/day1P2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>1787, 1373, 1709, 1514, 1807, 1791, 1724, 1859, 1590, 1976, 1572, 1947,
1913, 1995, 1728, 1624, 1731, 1706, 1782, 1994, 1851, 1843, 1773, 1982, 1685, 2001, 1346,
1200, 1746, 1520, 972, 1834, 1909, 2008, 1733, 1960, 1280, 1879, 1203, 1979, 1133, 1647,
1282, 1684, 860, 1444, 1780, 19... | code_fim | hard | {
"lang": "rust",
"repo": "kiraarghy/AOC_2020",
"path": "/day1P2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Foo for Placeholder {
const BLAH: &'static str = "hi";
}
fn foo(x: &str) {
match x {
<Placeholder as Foo>::BLAH => { }
_ => { }
}
}
fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/nll/issue-57280.rs
// build-pass (FIXME(62277): coul... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/nll/issue-57280.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match x {
<Placeholder as Foo>::BLAH => { }
_ => { }
}
}
fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/nll/issue-57280.rs
// build-pass (FIXME(62277): could be check-pass?)
trait Foo {
const BLAH: &'static str;
}
struct Placeholder;
... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/nll/issue-57280.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/nll/issue-57280.rs
// build-pass (FIXME(62277): could be check-pass?)
<|fim_suffix|> match x {
<Placeholder as Foo>::BLAH => { }
_ => { }
}
}
fn main() {}<|fim_middle|>trait Foo {
const BLAH: &'static str;
}
struct ... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/nll/issue-57280.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: okrplay/iodine_storage path: /src/resources/api.rs
// imports
use super::authentication::auth;
// resource struct
#[derive(Clone, Debug)]
pub struct APIResource;
<|fim_suffix|> match auth(authentication) {
Ok(msg) => Ok(CustomResponse { message: msg, status: 200 }),
... | code_fim | hard | {
"lang": "rust",
"repo": "okrplay/iodine_storage",
"path": "/src/resources/api.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> // endpoint to check if authentication with jwt is working
#[get("/api/authentication_check")]
#[content_type("json")]
fn authentication_check(&self, authentication: String) -> Result<CustomResponse, ()> {
match auth(authentication) {
Ok(msg) => ... | code_fim | medium | {
"lang": "rust",
"repo": "okrplay/iodine_storage",
"path": "/src/resources/api.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tiredhaydn/project_euler path: /src/bin/problem002/main.rs
fn main() {
let mut answer = 0;
let mut fib = (1, 2); // (odd, even)
whi<|fim_suffix|>odd)
fib = (fib.1, fib.0 + fib.1); // (odd, even)
}
println!("{}", answer);
}<|fim_middle|>le fib.1 <= ... | code_fim | medium | {
"lang": "rust",
"repo": "tiredhaydn/project_euler",
"path": "/src/bin/problem002/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>odd)
fib = (fib.1, fib.0 + fib.1); // (odd, even)
}
println!("{}", answer);
}<|fim_prefix|>// repo: tiredhaydn/project_euler path: /src/bin/problem002/main.rs
fn main() {
let mut answer = 0;
let mut fib = (1, 2); // (odd, even)
whi<|fim_middle|>le fib.1 <= ... | code_fim | medium | {
"lang": "rust",
"repo": "tiredhaydn/project_euler",
"path": "/src/bin/problem002/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: curx/huber path: /src/generator/src/pkg/pueue.rs
use huber_common::model::package::{Package, PackageManagement, PackageSource, PackageTargetType};
#[allow(dead_code)]
pub fn release() -> Package {
Package {
name: "pueue".to_string(),
source: PackageSource::Github {
... | code_fim | hard | {
"lang": "rust",
"repo": "curx/huber",
"path": "/src/generator/src/pkg/pueue.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ommands: None,
upgrade_commands: None,
tag_version_regex_template: None,
scan_dirs: None,
}),
PackageTargetType::Windows(PackageManagement {
artifact_templates: vec![
"{version}/pueue-windows-x86_64... | code_fim | hard | {
"lang": "rust",
"repo": "curx/huber",
"path": "/src/generator/src/pkg/pueue.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: willfindlay/rd path: /src/record_signal.rs
child_sa_addr.as_usize(),
0,
sigset_size
);
}
}
/// Restore the blocked-ness and sigaction for `sig` from `t`'s local
/// copy.
fn restore_signal_state(t: &RecordTask, sig: Sig, signal_was_blocked: SignalBlocke... | code_fim | hard | {
"lang": "rust",
"repo": "willfindlay/rd",
"path": "/src/record_signal.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let arch = t.arch();
rd_arch_function_selfless!(get_stub_scratch_1_arch, arch, t)
}
/// This function is responsible for handling breakpoints we set in syscallbuf
/// code to detect sigprocmask calls and syscallbuf exit. It's called when we
/// get a SIGTRAP. Returns true if the SIGTRAP was calle... | code_fim | hard | {
"lang": "rust",
"repo": "willfindlay/rd",
"path": "/src/record_signal.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !t.desched_rec().is_null() {
// We're already processing a desched. We probably reexecuted the
// system call (e.g. because a signal was processed) and the syscall
// blocked again. Carry on with the current desched.
} else {
// This prevents the syscallbuf recor... | code_fim | hard | {
"lang": "rust",
"repo": "willfindlay/rd",
"path": "/src/record_signal.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>"}
<a href="https://github.com/lukechu10" target="_blank">{"lukechu10"}</a>
</p>
<p>
{"Part of "}
<a href="http://todomvc.com">{"TodoMVC"}</a>
</p>
</footer>
}
}<|fim_prefix|>// repo: lukechu10/yew-functional-T... | code_fim | hard | {
"lang": "rust",
"repo": "lukechu10/yew-functional-TodoMVC",
"path": "/src/copyright.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lukechu10/yew-functional-TodoMVC path: /src/copyright.rs
use yew::prelude::*;
use yew_functional::*;
#[function_component(Copyright)]
pub fn copyright(_props: &()) -> Html {
html! {
<footer class="info">
<p>{"Double-click to edit a todo"}</p>
<p>
... | code_fim | hard | {
"lang": "rust",
"repo": "lukechu10/yew-functional-TodoMVC",
"path": "/src/copyright.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> insertion(&mut start);
assert_eq!(end, start);
}
}<|fim_prefix|>// repo: CosmicSyntax/algorithms path: /src/insertion/mod.rs
// Insertion Sort O(n^2)
pub fn insertion(a: &mut [i32]) {
let length = a.len();
for i in 1..length {
let key = a[i];
for j in (0..i).... | code_fim | medium | {
"lang": "rust",
"repo": "CosmicSyntax/algorithms",
"path": "/src/insertion/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn check_order() {
let mut start = [9, 1, 2, 8, 10, 10, 0];
let end = [0, 1, 2, 8, 9, 10, 10];
insertion(&mut start);
assert_eq!(end, start);
}
}<|fim_prefix|>// repo: CosmicSyntax/algorithms path: /src/insertion/mod.rs
// Insertion Sort O(n^2)
pub f... | code_fim | medium | {
"lang": "rust",
"repo": "CosmicSyntax/algorithms",
"path": "/src/insertion/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CosmicSyntax/algorithms path: /src/insertion/mod.rs
// Insertion Sort O(n^2)
pub fn insertion(a: &mut [i32]) {
let length = a.len();
for i in 1..length {
let key = a[i];
for j in (0..i).rev() {
if a[j] > key {
a.swap(j, j + 1);
}
... | code_fim | medium | {
"lang": "rust",
"repo": "CosmicSyntax/algorithms",
"path": "/src/insertion/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Happy-Ferret/cargo-pgo path: /src/main.rs
use std::process::Command;
use std::env;
use std::fs;
fn main() {
let mut args = env::args();
args.next().expect("program name");
match args.next() {
Some(ref s) if s == "pgo" => {
match args.next() {
Some... | code_fim | hard | {
"lang": "rust",
"repo": "Happy-Ferret/cargo-pgo",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn optimized(subcommand: &str, release_flag: bool, args: env::Args) {
let mut args = args.collect::<Vec<_>>();
if release_flag {
args.insert(0, "--release".to_string());
}
if !merge_profiles() {
println!("Warning: no profiling data was found - this build will not be PGO-opt... | code_fim | hard | {
"lang": "rust",
"repo": "Happy-Ferret/cargo-pgo",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: llogiq/koto path: /libs/lib_tests/tests/lib_tests.rs
use {
koto::{Koto, KotoSettings},
std::{fs::read_to_string, path::PathBuf},
};
fn run_script(script: &str, path: Option<PathBuf>, should_fail_at_runtime: bool) {
let mut koto = Koto::with_settings(KotoSettings {
run_tests:... | code_fim | medium | {
"lang": "rust",
"repo": "llogiq/koto",
"path": "/libs/lib_tests/tests/lib_tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> load_and_run_script(&format!("{}.koto", stringify!($name)));
}
};
}
mod lib_tests {
use super::*;
lib_test!(json);
lib_test!(random);
lib_test!(tempfile);
lib_test!(toml);
}<|fim_prefix|>// repo: llogiq/koto path: /libs/lib_tests/tests/lib_tests.rs
use {
... | code_fim | medium | {
"lang": "rust",
"repo": "llogiq/koto",
"path": "/libs/lib_tests/tests/lib_tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>macro_rules! lib_test {
($name:ident) => {
#[test]
fn $name() {
load_and_run_script(&format!("{}.koto", stringify!($name)));
}
};
}
mod lib_tests {
use super::*;
lib_test!(json);
lib_test!(random);
lib_test!(tempfile);
lib_test!(toml);
}<|f... | code_fim | hard | {
"lang": "rust",
"repo": "llogiq/koto",
"path": "/libs/lib_tests/tests/lib_tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn push(&self, value: T) -> Self{
// add an element with value T to the front of the skiplist.
//add your code here
match self{
HeadNode(up, right) => right.push(value),
ValueNode(val, up, right, down, left) => if value < *val {
unsafe{
... | code_fim | hard | {
"lang": "rust",
"repo": "ECE421Group11/Assignment4",
"path": "/q4/src/v3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ECE421Group11/Assignment4 path: /q4/src/v3.rs
use std::cell::RefCell;
use std::cell::Ref;
use std::mem;
use std::clone::Clone;
#[derive(Debug, Clone)]
pub enum SkipList<T>{
//add your code here
HeadNode(Box<SkipList<T>>, Box<SkipList<T>>), // up, right
ValueNode(T, Box<SkipList<T>>,... | code_fim | hard | {
"lang": "rust",
"repo": "ECE421Group11/Assignment4",
"path": "/q4/src/v3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn len(&self) -> usize{
// returns the number of elements at level 0 of the skip list.
//add your code here
match self{
HeadNode(up, right) => right.len(),
ValueNode(val, up, right, down, left) => 1 + right.len(),
TailNode => 0
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ECE421Group11/Assignment4",
"path": "/q4/src/v3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let path = match retrieve_capture(line, PATH_REGEX) {
Some(x) => PathBuf::from(x),
None => return None,
};
let pid = match retrieve_capture(line, PID_REGEX) {
Some(x) => Pid::new(x),
None => return None,
};
let proce... | code_fim | hard | {
"lang": "rust",
"repo": "brianp/muxed",
"path": "/snapshot/src/tmux/pane/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brianp/muxed path: /snapshot/src/tmux/pane/mod.rs
//use std::path::PathBuf;
//use tmux::window::Window;
use capture::retrieve_capture;
use serde::{Deserialize, Serialize, Serializer};
use std::io;
use std::path::PathBuf;
use std::process::{Command, Output};
pub mod pid;
pub mod process;
use se... | code_fim | hard | {
"lang": "rust",
"repo": "brianp/muxed",
"path": "/snapshot/src/tmux/pane/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let line = "1: [123x14] (Path: /muxed-project/muxed) (PID: 22541) (active)";
let pane = Pane::from_line(line).unwrap();
assert!(pane.active)
}
#[test]
fn expect_pane_to_match() {
let line = "1: [123x14] (Path: /muxed/muxedsnapshot) (PID: 22541) (active)";
... | code_fim | hard | {
"lang": "rust",
"repo": "brianp/muxed",
"path": "/snapshot/src/tmux/pane/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// #[cfg(target_family="unix")]
// impl AppTerminal {
// #[cfg(target_family="unix")]
// pub fn create() -> AppTerminal {
// let stdout = io::stdout();
// let raw_terminal = stdout.into_raw_mode().expect("Failed to acquire standard output in raw mode.");
// let backend = Te... | code_fim | hard | {
"lang": "rust",
"repo": "daball/tilde-table",
"path": "/refresh-in-rust/src/app/state.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// #[cfg(target_family="unix")]
// use tui::backend::TermionBackend;
// #[cfg(target_family="unix")]
// use termion::raw::{IntoRawMode, RawTerminal};
// #[cfg(target_family="windows")]
// use tui::backend::CrosstermBackend;
// #[cfg(target_family="windows")]
// pub struct AppTerminal {
// pub termina... | code_fim | hard | {
"lang": "rust",
"repo": "daball/tilde-table",
"path": "/refresh-in-rust/src/app/state.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daball/tilde-table path: /refresh-in-rust/src/app/state.rs
use crate::app::commands::clear::ClearCommand;
use crate::app::commands::exit::ExitCommand;
use crate::app::commands::help::HelpCommand;
use crate::app::commands::history::HistoryCommand;
use crate::app::commands::list::ListCommand;
use ... | code_fim | hard | {
"lang": "rust",
"repo": "daball/tilde-table",
"path": "/refresh-in-rust/src/app/state.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> color_strip.clear(Color::black());
for effect in &mut self.effects {
effect.paint(&mut color_strip);
effect.tick();
}
self.opc_strip.send(&color_strip);
thread::sleep(Duration::from_millis(10));
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "shybyte/midi2opc",
"path": "/src/midi_light_strip.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shybyte/midi2opc path: /src/midi_light_strip.rs
use opc_strip::OpcStrip;
use std::io;
use color_strip::ColorStrip;
use effects::effect::Effect;
use effects::ripple::Ripple;
use effects::flash::Flash;
use effects::blink::Blink;
use effects::stream::Stream;
use effects::push::Push;
use effects::r... | code_fim | hard | {
"lang": "rust",
"repo": "shybyte/midi2opc",
"path": "/src/midi_light_strip.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qhyw99/TimedCommitment path: /src/lib.rs
#![allow(non_snake_case)]
extern crate curv;
extern crate bulletproof;
pub use curv::*;
use curv::elliptic::curves::rsa_group::*;
use curv::elliptic::curves::curve_ristretto::*;
use crate::timeline_calculator::*;
use crate::proof_system::{Statement, proo... | code_fim | hard | {
"lang": "rust",
"repo": "qhyw99/TimedCommitment",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //Verify
let status = verify(mtl.clone(), &statement, proofs);
let message_commitment = statement.get_message_commitment();
let rk_0 = statement.get_rk0();
let s = secret.as_ref(); //m r
//Force open
if status {
let b = force_open_message(&msg_0, &msg_1, message_commit... | code_fim | medium | {
"lang": "rust",
"repo": "qhyw99/TimedCommitment",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.