text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>
// Header
let header_paint = Gradient::Linear {
start: Point::new(x, y),
end: Point::new(x, y+15.0),
start_color: Color::rgba_i(255, 255, 255, 5),
end_color: Color::rgba_i(0, 0, 0, 16)
};
ctx.begin_path();
ctx.rounded_rect(
Rect::from((x+1.0, y+... | code_fim | hard | {
"lang": "rust",
"repo": "othelarian/curly-succotash",
"path": "/src/drawing/window.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // nvgFontBlur(vg,2) : TODO: implement nvgFontBlur in nvg
ctx.fill_paint(Color::rgba_i(0, 0, 0, 128));
ctx.text((x+w/2.0, y+16.0), title).unwrap();
// nvgFontBlur(vg,0) : TODO: implement nvgFontBlur in nvg
ctx.fill_paint(Color::rgba_i(220,220,220,160));
ctx.text((x+w/2.0, y+16.0),... | code_fim | hard | {
"lang": "rust",
"repo": "othelarian/curly-succotash",
"path": "/src/drawing/window.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: othelarian/curly-succotash path: /src/drawing/window.rs
use nvg::{Context, Rect, Point, Color, Gradient, Solidity, Align};
use nvg_gl::Renderer;
pub fn draw (
mut ctx: Context<Renderer>,
title: &str,
x: f32,
y: f32,
w: f32,
h: f32
) -> Context<Renderer> {
let corner_... | code_fim | medium | {
"lang": "rust",
"repo": "othelarian/curly-succotash",
"path": "/src/drawing/window.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wezm/dslite2svd path: /crates/tm4c123x/src/gpio_porta/mod.rs
#[doc = r" Register block"]
#[repr(C)]
pub struct RegisterBlock {
_reserved0: [u8; 1020usize],
#[doc = "0x3fc - GPIO Data"]
pub data: DATA,
#[doc = "0x400 - GPIO Direction"]
pub dir: DIR,
#[doc = "0x404 - GPIO I... | code_fim | hard | {
"lang": "rust",
"repo": "wezm/dslite2svd",
"path": "/crates/tm4c123x/src/gpio_porta/mod.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|>p Select"]
pub mod pur;
#[doc = "GPIO Pull-Down Select"]
pub struct PDR {
register: ::vcell::VolatileCell<u32>,
}
#[doc = "GPIO Pull-Down Select"]
pub mod pdr;
#[doc = "GPIO Slew Rate Control Select"]
pub struct SLR {
register: ::vcell::VolatileCell<u32>,
}
#[doc = "GPIO Slew Rate Control Select"]... | code_fim | hard | {
"lang": "rust",
"repo": "wezm/dslite2svd",
"path": "/crates/tm4c123x/src/gpio_porta/mod.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Bind address.
let addr: SocketAddrV4 = {
let port: u16 = 8080;
SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, port)
};
// Fail to bind socket.
// FIXME: https://github.com/demikernel/demikernel/issues/189
match libos.bind(sockqd, addr) {
Err(e) if e.errno == l... | code_fim | hard | {
"lang": "rust",
"repo": "jthelin/demikernel",
"path": "/tests/rust/tcp-test/bind/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jthelin/demikernel path: /tests/rust/tcp-test/bind/mod.rs
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//======================================================================================================================
// Imports
//============================... | code_fim | hard | {
"lang": "rust",
"repo": "jthelin/demikernel",
"path": "/tests/rust/tcp-test/bind/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Create a TCP socket.
let sockqd: QDesc = libos.socket(AF_INET, SOCK_STREAM, 0)?;
// Bind address.
let addr: SocketAddrV4 = {
let port: u16 = 8080;
SocketAddrV4::new(*remote, port)
};
// Fail to bind socket.
match libos.bind(sockqd, addr) {
Err(e) if... | code_fim | hard | {
"lang": "rust",
"repo": "jthelin/demikernel",
"path": "/tests/rust/tcp-test/bind/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bostjanv/wintracer path: /examples/trace.rs
use std::collections::HashMap;
use std::env::args;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::path::Path;
use wintracer::{ContinueStatus, DebugEventKind, ExceptionCode, WinTracer};
fn main() -> Result<(), &'static str... | code_fim | hard | {
"lang": "rust",
"repo": "bostjanv/wintracer",
"path": "/examples/trace.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match event.kind {
DebugEventKind::Exception(e) => match e.code {
ExceptionCode::Wx86Breakpoint => {
let counter = hits.entry(e.address).or_insert(0);
*counter += 1;
... | code_fim | hard | {
"lang": "rust",
"repo": "bostjanv/wintracer",
"path": "/examples/trace.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: foxfriends/lumber path: /src/test/conjunction.rs
use super::*;
test! {
simple_conjunction => r#"
:- pub(test/2).
hello(a).
test(A, B) :- hello(A), hello(B).
"#
?- "test(a, a)";
?- "test(a, _)";
?- "test(_, _)";
?- "test(_, a)";
?- "test(A, B)"
A =... | code_fim | hard | {
"lang": "rust",
"repo": "foxfriends/lumber",
"path": "/src/test/conjunction.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>test! {
conjunction_different_wildcards => r#"
:- pub(test/1).
left(a).
right(b).
test(C) :-
left(C),
right(C).
"#
?- "test(_)"
?- "test(a)"
?- "test(b)"
}<|fim_prefix|>// repo: foxfriends/lumber path: /src/test/conjunction.rs
use super::*;
test! {
... | code_fim | hard | {
"lang": "rust",
"repo": "foxfriends/lumber",
"path": "/src/test/conjunction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let filename = "test_files/desktop_entries/test-multiple.desktop";
let desktop_file = DesktopEntry::from_file(filename).unwrap();
let groups = desktop_file.groups;
let default_group = groups.get(0).unwrap();
assert_eq!(default_group.check_group().is_ok(), true);
let filename = "tes... | code_fim | hard | {
"lang": "rust",
"repo": "A6GibKm/rust-xdg",
"path": "/src/desktop_entry/test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: A6GibKm/rust-xdg path: /src/desktop_entry/test.rs
use crate::desktop_entry::DesktopEntry;
#[test]
fn parse_desktop_file() {
let filename = "test_files/desktop_entries/test-multiple.desktop";
let desktop_file = DesktopEntry::from_file(filename).unwrap();
let groups = desktop_file.gro... | code_fim | medium | {
"lang": "rust",
"repo": "A6GibKm/rust-xdg",
"path": "/src/desktop_entry/test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>antae::flower::Flower>,
) -> Entity {
world
.specs_world
.create_entity()
.with(Position::new(x, y))
.with(Plantae::new(instance))
.build()
}<|fim_prefix|>// repo: andrewvy/settlers_of_lore path: /src/entities.rs
use specs::prelude::*;
use components::*;
use p... | code_fim | medium | {
"lang": "rust",
"repo": "andrewvy/settlers_of_lore",
"path": "/src/entities.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>)
.with(Position::new(x, y))
.with(Plantae::new(instance))
.build()
}<|fim_prefix|>// repo: andrewvy/settlers_of_lore path: /src/entities.rs
use specs::prelude::*;
use components::*;
use plantae;
use world::World;
pub fn create_flower(
world: &mut World,
x: i32,
y: i... | code_fim | medium | {
"lang": "rust",
"repo": "andrewvy/settlers_of_lore",
"path": "/src/entities.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrewvy/settlers_of_lore path: /src/entities.rs
use specs::prelude::*;
use components::*;
use plantae;
use world::World;
pub fn create_flower(
world: &mut World,
x: i32,
y: i32,
instance: plantae::PlantaeInstance<pl<|fim_suffix|>)
.with(Position::new(x, y))
.wi... | code_fim | medium | {
"lang": "rust",
"repo": "andrewvy/settlers_of_lore",
"path": "/src/entities.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kedstar99/Rustendo64 path: /src/cpu/cpu.rs
use super::super::interconnect;
use super::cp0;
use super::instruction as cpu_i;
use std::fmt;
//see Google drive for CPU spec
pub struct Cpu {
gpr: [u64; 32],
fpr: [f64; 32],
pc: u64,
high: u64,
low: u64,
llbit: bool,
fcr0... | code_fim | hard | {
"lang": "rust",
"repo": "Kedstar99/Rustendo64",
"path": "/src/cpu/cpu.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let phys_addr = self.virt_phys_addr_mapping(virt_addr);
self.interconnect.write_word(phys_addr as u32, data)
}
fn virt_phys_addr_mapping(&self, virt_addr: u64) -> u64 {
// see table 5-3 of processor VR4300 user manual
let addr_bit_values = (virt_addr >> 29) & 0b111... | code_fim | hard | {
"lang": "rust",
"repo": "Kedstar99/Rustendo64",
"path": "/src/cpu/cpu.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("The void function");
}
// Parameters with no return
fn func_2(x: int, y: f32, z: bool) {
println!("Parameterized Function");
println!(" An Integer: {}",x);
println!(" A float: {}",y);
println!(" A boolean: {}",z);
}
// With return values
fn func_3(x: int,y: int) -> i... | code_fim | medium | {
"lang": "rust",
"repo": "DarkLinkXXXX/rust-by-example",
"path": "/src/functions/functions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DarkLinkXXXX/rust-by-example path: /src/functions/functions.rs
/**
* functions.rs : A cursory introduction to rust functions.
*
* Functions in Rust are declared by the keyword 'fn'.
* The basic syntax is:
* fn my_function(my_var: int) -> ret_val {
* ...
* return ret_va... | code_fim | hard | {
"lang": "rust",
"repo": "DarkLinkXXXX/rust-by-example",
"path": "/src/functions/functions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Main function is always called first in a Rust program.
fn main() {
func_1();
func_2(2, 3.14159265, true);
println!("Value returned : {}",func_3(42, 378));
}<|fim_prefix|>// repo: DarkLinkXXXX/rust-by-example path: /src/functions/functions.rs
/**
* functions.rs : A cursory introduction to... | code_fim | hard | {
"lang": "rust",
"repo": "DarkLinkXXXX/rust-by-example",
"path": "/src/functions/functions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Devolutions/nng-rs path: /src/aio.rs
of milliseconds
/// before responding:
///
/// ```
/// use std::time::Duration;
/// use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
/// use nng::*;
///
/// const ADDRESS: &'static str = "inproc://nng/aio/example";
/// const WORKERS: usize = 10;
/... | code_fim | hard | {
"lang": "rust",
"repo": "Devolutions/nng-rs",
"path": "/src/aio.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Devolutions/nng-rs path: /src/aio.rs
eads. Instead the application registers a “callback” function to be
/// executed when the operation is complete (whether successfully or not). This
/// callback will be executed exactly once.
///
/// The callback must not perform any blocking operations and m... | code_fim | hard | {
"lang": "rust",
"repo": "Devolutions/nng-rs",
"path": "/src/aio.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let old_state = self.inner.state.compare_and_swap(inactive, sending, Ordering::AcqRel);
if old_state == inactive {
let aiop = self.inner.handle.load(Ordering::Relaxed);
unsafe {
nng_sys::nng_aio_set_msg(aiop, msg.into_ptr().as_ptr());
nng_sys::nng_ctx_send(ctx.handle(), aiop);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Devolutions/nng-rs",
"path": "/src/aio.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_reset_add_delta_gauge_metric() {
let mut buckets = Buckets::default();
let rmname = String::from("some.metric");
let metric = Telemetry::new("some.metric", 100.0).aggr_set();
buckets.add(metric);
let delta_metric = Telemetry::new("some.metric... | code_fim | hard | {
"lang": "rust",
"repo": "skade/cernan",
"path": "/src/buckets.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skade/cernan path: /src/buckets.rs
//buckets.reset();
/// //assert_eq!(true, buckets.is_empty());
/// ```
pub fn reset(&mut self) {
self.count = 0;
for v in &mut self.values {
if v.is_empty() {
continue;
}
let len = ... | code_fim | hard | {
"lang": "rust",
"repo": "skade/cernan",
"path": "/src/buckets.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skade/cernan path: /src/buckets.rs
dd(m0);
bkt.add(m1);
// * it is possible to switch a SET|SUM from persist to ephemeral
// * an ephemeral SET|SUM will have its value inherited by a persist SET|SUM
let aggrs = bkt.clone();
let res = aggrs.get("lO").unw... | code_fim | hard | {
"lang": "rust",
"repo": "skade/cernan",
"path": "/src/buckets.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ackintosh/pbft path: /src/behavior.rs
use libp2p::core::ConnectedPoint;
use libp2p::swarm::{PollParameters, NetworkBehaviour, NetworkBehaviourAction};
use libp2p::multiaddr::Multiaddr;
use std::error::Error;
use tokio::prelude::{AsyncRead, AsyncWrite, Async};
use libp2p::PeerId;
use std::collect... | code_fim | hard | {
"lang": "rust",
"repo": "ackintosh/pbft",
"path": "/src/behavior.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("[Pbft::inject_connected] peer_id: {:?}, connected_point: {:?}", peer_id, connected_point);
// match connected_point {
// ConnectedPoint::Dialer { address } => {
// },
// ConnectedPoint::Listener { .. } => {}
// };
self.connected_peer... | code_fim | hard | {
"lang": "rust",
"repo": "ackintosh/pbft",
"path": "/src/behavior.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
}
#[test_suite]
mod int_id_create_cockroachdb {
use indoc::indoc;
fn schema_int_autoinc() -> String {
let schema = indoc! {
r#"model Todo {
#id(id, BigInt, @id, @default(autoincrement()))
title String
}"#
};... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/ids/int_id_create.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn bubble_sort(vec: &mut Vec<u32>) -> History {
let mut history = Vec::new();
for j in (0..vec.len()).rev() {
for i in 0..j {
if cmp(&vec, &mut history, i, i+1) {
vec.swap(i, i+1);
history.push(Swap(i, i+1));
}
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "tertsdiepraam/Sorters",
"path": "/src/sort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tertsdiepraam/Sorters path: /src/sort.rs
use crate::vecviz::{
History,
HistoryElement,
};
use HistoryElement::*;
fn cmp(v: &Vec<u32>, h: &mut History, i: usize, j: usize) -> bool {
h.push(Compare(i, j));
v[i] > v[j]
}
pub fn insertion_sort(vec: &mut Vec<u32>) -> History {
... | code_fim | hard | {
"lang": "rust",
"repo": "tertsdiepraam/Sorters",
"path": "/src/sort.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
// Put `memory.x` in our output directory and ensure it's
// on the linker search path.
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("memory.x"))
.unwrap();
println!... | code_fim | medium | {
"lang": "rust",
"repo": "rust-embedded/discovery",
"path": "/microbit/src/09-led-compass/build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-embedded/discovery path: /microbit/src/09-led-compass/build.rs
//! This build script copies the `memory.x` file from the crate root into
//! a directory where the linker can always find it at build time.
//! For many projects this is optional, as the linker always searches the
//! project r... | code_fim | medium | {
"lang": "rust",
"repo": "rust-embedded/discovery",
"path": "/microbit/src/09-led-compass/build.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // O(n) since self.pop() is O(1), and we are calling self.pop() n times (once per element).
// Also O(n) in space, since we create and allocate elements in a new list.
pub fn rev(mut self) -> Self {
let mut reversed_list = Self::new();
while let Some(node) = self.pop() {
... | code_fim | hard | {
"lang": "rust",
"repo": "rkr35/exercism-rust-track-solutions",
"path": "/simple-linked-list/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rkr35/exercism-rust-track-solutions path: /simple-linked-list/src/lib.rs
#![warn(clippy::pedantic)]
type HeapNode<T> = Box<Node<T>>;
type MaybeNode<T> = Option<HeapNode<T>>;
struct Node<T> {
data: T,
next: MaybeNode<T>,
}
impl<T> From<T> for Node<T> {
fn from(data: T) -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "rkr35/exercism-rust-track-solutions",
"path": "/simple-linked-list/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // O(1) because &mut self has direct access to self.head.
pub fn pop(&mut self) -> Option<T> {
let popped = self.head.take()?;
self.head = popped.next;
self.length -= 1;
Some(popped.data)
}
// O(1) since &self has direct access to self.head.
pub fn peek... | code_fim | hard | {
"lang": "rust",
"repo": "rkr35/exercism-rust-track-solutions",
"path": "/simple-linked-list/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>c = "Bits 24:25 - NUM_PADS1"]
#[inline(always)]
pub fn num_pads1(&self) -> NUM_PADS1_R {
NUM_PADS1_R::new(((self.bits >> 24) & 0x03) as u8)
}
#[doc = "Bits 26:31 - OPCODE1"]
#[inline(always)]
pub fn opcode1(&self) -> OPCODE1_R {
OPCODE1_R::new(((self.bits >> 26) & 0... | code_fim | hard | {
"lang": "rust",
"repo": "Shock-1/teensy4-rs",
"path": "/imxrt1062-pac/imxrt1062-flexspi/src/lut.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Shock-1/teensy4-rs path: /imxrt1062-pac/imxrt1062-flexspi/src/lut.rs
#[doc = "Reader of register LUT[%s]"]
pub type R = crate::R<u32, super::LUT>;
#[doc = "Writer for register LUT[%s]"]
pub type W = crate::W<u32, super::LUT>;
#[doc = "Register LUT[%s]
`reset()`'s with value 0"]
impl crate::Reset... | code_fim | hard | {
"lang": "rust",
"repo": "Shock-1/teensy4-rs",
"path": "/imxrt1062-pac/imxrt1062-flexspi/src/lut.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Phlosioneer/ggez path: /examples/render_to_image.rs
//! An example of how to render to images using the `Canvas` type.
extern crate ggez;
use ggez::conf;
use ggez::event;
use ggez::graphics::{self, Color, DrawParam, Point2};
use ggez::{Context, GameResult};
struct MainState {
canvas: grap... | code_fim | hard | {
"lang": "rust",
"repo": "Phlosioneer/ggez",
"path": "/examples/render_to_image.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let new_rect = graphics::Rect::new(0.0, 0.0, width as f32, height as f32);
graphics::set_screen_coordinates(ctx, new_rect).unwrap();
}
}
pub fn main() {
let mut c = conf::Conf::new();
c.window_setup.resizable = true;
let ctx = &mut Context::load_from_conf("super_simple", "... | code_fim | hard | {
"lang": "rust",
"repo": "Phlosioneer/ggez",
"path": "/examples/render_to_image.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ans = 0;
for i in 0..h {
for j in 0..w {
if j + 1 < w {
if s[i][j] == '.' && s[i][j + 1] == '.' {
ans += 1;
}
}
if i + 1 < h {
if s[i][j] == '.' && s[i + 1][j] == '.' {
... | code_fim | medium | {
"lang": "rust",
"repo": "matsutake-eg/atcoder",
"path": "/rust/hhkb2020/src/bin/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matsutake-eg/atcoder path: /rust/hhkb2020/src/bin/b.rs
#![allow(unused_imports)]
use itertools::Itertools;
use itertools_num::ItertoolsNum as _;
use num_integer::*;
use petgraph::*;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;
<|fim_suffix|> let... | code_fim | hard | {
"lang": "rust",
"repo": "matsutake-eg/atcoder",
"path": "/rust/hhkb2020/src/bin/b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Find the first thread that is not marked as busy and schedule this task on it
for &(ref busy_rc, ref thread) in threads.iter() {
let mut busy = busy_rc.lock().expect("Thread busy lock");
if !*busy {
// Clone the busy mutex so we can return this t... | code_fim | hard | {
"lang": "rust",
"repo": "anlumo/desync",
"path": "/src/scheduler/core.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anlumo/desync path: /src/scheduler/core.rs
use super::scheduler_thread::*;
use super::job_queue::*;
use super::queue_state::*;
use super::wake_queue::*;
use std::sync::*;
use std::collections::vec_deque::*;
use futures::task;
use futures::task::{Context};
///
/// The scheduler core contains t... | code_fim | hard | {
"lang": "rust",
"repo": "anlumo/desync",
"path": "/src/scheduler/core.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> job_data
};
// Run the job if there is one, stop the thread if there is not
if let Some(job_data) = job_data {
job(job_data);
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "anlumo/desync",
"path": "/src/scheduler/core.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sebastinez/ethers-ws-events path: /src/org.rs
pub use org_mod::*;
#[allow(clippy::too_many_arguments)]
mod org_mod {
#![allow(dead_code)]
#![allow(unused_imports)]
use ethers::{
contract::{
self as ethers_contract,
builders::{ContractCall, Event},
... | code_fim | hard | {
"lang": "rust",
"repo": "sebastinez/ethers-ws-events",
"path": "/src/org.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
OrgEvents::AnchoredFilter(element) => element.into_token(),
OrgEvents::NameChangedFilter(element) => element.into_token(),
OrgEvents::OwnerChangedFilter(element) => element.into_token(),
OrgEvents::UnanchoredFilter(el... | code_fim | hard | {
"lang": "rust",
"repo": "sebastinez/ethers-ws-events",
"path": "/src/org.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn parse<T: syn::parse::Parse>(&self) -> T {
match &self {
Attribute::KeyValue {
path,
lit: syn::Lit::Str(lit_str),
} => lit_str
.parse()
.expect_or_abort(&format!("Expected {:?} to be path", path)),
... | code_fim | hard | {
"lang": "rust",
"repo": "erglabs/common-tools-rs",
"path": "/crates/rpc_dto/src/attrs.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erglabs/common-tools-rs path: /crates/rpc_dto/src/attrs.rs
use proc_macro_error::{abort, ResultExt};
pub enum Attribute {
KeyValue { path: syn::Path, lit: syn::Lit },
Toggle { path: syn::Path },
}
impl Attribute {
pub fn toggled(&self, cond: &syn::Path) -> bool {
match self... | code_fim | hard | {
"lang": "rust",
"repo": "erglabs/common-tools-rs",
"path": "/crates/rpc_dto/src/attrs.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn recover_public_key(
&self,
message: &Trits<T1B1>,
) -> Result<Self::PublicKey, <Self as RecoverableSignature>::Error> {
if message.len() != HASH_LENGTH {
return Err(Error::InvalidMessageLength(message.len()));
}
let mut sponge = S::default();... | code_fim | hard | {
"lang": "rust",
"repo": "thibault-martinez/bee",
"path": "/bee-signing/src/ternary/wots/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thibault-martinez/bee path: /bee-signing/src/ternary/wots/mod.rs
// Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
//! Winternitz One Time Signature scheme.
//! <https://eprint.iacr.org/2011/191.pdf>.
mod normalize;
mod shake;
mod sponge;
pub use normalize::{normaliz... | code_fim | hard | {
"lang": "rust",
"repo": "thibault-martinez/bee",
"path": "/bee-signing/src/ternary/wots/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if state.len() % SIGNATURE_FRAGMENT_LENGTH != 0 {
return Err(Error::InvalidSignatureLength(state.len()));
}
Ok(Self {
state,
marker: PhantomData,
})
}
fn as_trits(&self) -> &Trits<T1B1> {
&self.state
}
}
impl<S: Spo... | code_fim | hard | {
"lang": "rust",
"repo": "thibault-martinez/bee",
"path": "/bee-signing/src/ternary/wots/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Config {
app_directory: PathBuf::from(app_directory),
download_directory: PathBuf::from(download_directory),
}
}
fn create_app() -> Application {
let config = create_config();
ApplicationBuilder::new(config).episodes_subcommand().build()
... | code_fim | hard | {
"lang": "rust",
"repo": "dmitryshur/podcasts",
"path": "/src/episodes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut writers = HashMap::new();
writers.insert(15913066141282366353, Vec::new());
episodes.update(&podcasts, &mut writers);
let syntax_output_string = from_utf8(writers.get(&15913066141282366353).unwrap()).unwrap();
assert_eq!(syntax_output_string.trim(), syntax... | code_fim | hard | {
"lang": "rust",
"repo": "dmitryshur/podcasts",
"path": "/src/episodes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dmitryshur/podcasts path: /src/episodes.rs
_id.is_err() {
return None;
}
Some((file_id.unwrap(), file.unwrap()))
})
.collect();
for file i... | code_fim | hard | {
"lang": "rust",
"repo": "dmitryshur/podcasts",
"path": "/src/episodes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/no-landing-pads.rs
// run-pass
// compile-flags: -Z no-landing-pads -C codegen-units=1
// ignore-emscripten no threads support
use std::thread;
static mut HIT: bool = false;
struct A;
impl Drop for A {
fn drop(&mut self) {
<|fim_suffix|>... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/no-landing-pads.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
thread::spawn(move|| -> () {
let _a = A;
panic!();
}).join().unwrap_err();
assert!(unsafe { !HIT });
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/no-landing-pads.rs
// run-pass
// compile-flags: -Z no-landing-pads -C codegen-units=1
//... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/no-landing-pads.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let parent = matches.get(1).unwrap().as_str().to_owned();
let mut suffix = &line[matches.get(0).unwrap().end()..];
while let Some(matches) = child_reg.captures(suffix) {
let count = matches
.get(1)
.unwrap()
... | code_fim | hard | {
"lang": "rust",
"repo": "johningve/adventofcode",
"path": "/2020/rust/src/days/day7.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut day7 = Self::default();
let parent_reg = Regex::new(r"([\w ]+?) bags contain").unwrap();
let child_reg = Regex::new(r"(\d+) ([\w ]+?) bag").unwrap();
for ref line in lines {
let matches = match parent_reg.captures(line) {
Some(matches) =... | code_fim | hard | {
"lang": "rust",
"repo": "johningve/adventofcode",
"path": "/2020/rust/src/days/day7.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johningve/adventofcode path: /2020/rust/src/days/day7.rs
use crate::solver::Solver;
use crate::util::push_key;
use regex::Regex;
use std::collections::{HashMap, HashSet, VecDeque};
#[derive(Clone)]
struct BagRule {
name: String,
number: i32,
}
#[derive(Default)]
pub struct Day7 {
c... | code_fim | hard | {
"lang": "rust",
"repo": "johningve/adventofcode",
"path": "/2020/rust/src/days/day7.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(players_vec)
}
pub fn json_to_string(json: &Value) -> Result<String> {
Ok(serde_json::to_string(json)?)
}
pub fn print_json(json: &Value) -> Result<()> {
let j = serde_json::to_string(json)?;
println!("{}", j);
Ok(())
}
pub fn bytes_to_char_and_map(bytes: &[u8]) -> String {
b... | code_fim | hard | {
"lang": "rust",
"repo": "2vg/valve-server-query",
"path": "/src/parser/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 2vg/valve-server-query path: /src/parser/mod.rs
extern crate anyhow;
extern crate binary_parser;
extern crate serde;
extern crate serde_json;
use binary_parser::parser::BinaryParser;
use anyhow::*;
use serde_json::{json, Value, Result};
pub fn parse_info_response(response: Vec<u8>) -> anyhow:... | code_fim | hard | {
"lang": "rust",
"repo": "2vg/valve-server-query",
"path": "/src/parser/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn json_to_string(json: &Value) -> Result<String> {
Ok(serde_json::to_string(json)?)
}
pub fn print_json(json: &Value) -> Result<()> {
let j = serde_json::to_string(json)?;
println!("{}", j);
Ok(())
}
pub fn bytes_to_char_and_map(bytes: &[u8]) -> String {
bytes.iter().map(|&s| fo... | code_fim | hard | {
"lang": "rust",
"repo": "2vg/valve-server-query",
"path": "/src/parser/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tnowacki/libra path: /language/move-analyzer/src/vfs.rs
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
//! The language server must operate upon Move source buffers as they are being edited.
//! As a result, it is frequently queried about buffers that have no... | code_fim | hard | {
"lang": "rust",
"repo": "tnowacki/libra",
"path": "/language/move-analyzer/src/vfs.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Removes the buffer and its identifier from the system.
pub fn remove(&mut self, identifier: &str) {
self.files.remove(identifier);
}
}
/// Updates the given virtual file system based on the text document sync notification that was sent.
pub fn on_text_document_sync_notification(
... | code_fim | hard | {
"lang": "rust",
"repo": "tnowacki/libra",
"path": "/language/move-analyzer/src/vfs.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Create the context attributes
let context_attributes: [c_int; 5] = [
GLX_CONTEXT_MAJOR_VERSION_ARB as c_int, 3,
GLX_CONTEXT_MINOR_VERSION_ARB as c_int, 0,
0
];
// And finally, create the context itself
let ctx = unsafe {
glx_create_context_attribs(x_... | code_fim | hard | {
"lang": "rust",
"repo": "crsaracco/vst2-window",
"path": "/src/platform/x11/gl_utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: crsaracco/vst2-window path: /src/platform/x11/gl_utils.rs
// TODO: This file is pretty dang messy. Clean up.
use std::ffi::{CStr, CString};
use std::os::raw::{c_int, c_void};
use std::ptr::null_mut;
use std::sync::Arc;
use x11::{glx, xlib};
use log::*;
use super::x_handle;
type GlXCreateCont... | code_fim | hard | {
"lang": "rust",
"repo": "crsaracco/vst2-window",
"path": "/src/platform/x11/gl_utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ne)]
pub struct pv_chunk__bindgen_ty_1 {
pub tqe_next: *mut pv_chunk,
pub tqe_prev: *mut *mut pv_chunk,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct pv_chunk__bindgen_ty_2 {
pub tqe_next: *mut pv_chunk,
pub tqe_prev: *mut *mut pv_chunk,
}
pub type vm_flags_t = u_char;
pub type vm_... | code_fim | hard | {
"lang": "rust",
"repo": "benfred/remoteprocess",
"path": "/src/freebsd/kinfo_proc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benfred/remoteprocess path: /src/freebsd/kinfo_proc.rs
debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
let index = i... | code_fim | hard | {
"lang": "rust",
"repo": "benfred/remoteprocess",
"path": "/src/freebsd/kinfo_proc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>_ty_2 {
pub lh_first: *mut proc_,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct pargs {
pub ar_ref: u_int,
pub ar_length: u_int,
pub ar_args: [u_char; 1usize],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct cpuset {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Cl... | code_fim | hard | {
"lang": "rust",
"repo": "benfred/remoteprocess",
"path": "/src/freebsd/kinfo_proc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut uuid = [0u8; 16];
uuid.copy_from_slice(&buf[1..17]);
Ok((Uuid::from_slice(&uuid)?, 17))
}
}
impl<'a> Encode for &'a str {
fn encode<W: Write>(&self, w: &mut W, _tuple_depth: TupleDepth) -> std::io::Result<()> {
STRING.write(w)?;
encode_bytes(w, sel... | code_fim | hard | {
"lang": "rust",
"repo": "schallert/foundationdb-rs",
"path": "/foundationdb/src/tuple/element.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: schallert/foundationdb-rs path: /foundationdb/src/tuple/element.rs
<< (6 * 8)) - 1,
(1 << (7 * 8)) - 1,
u64::max_value(),
];
/// A single tuple element
#[derive(Clone, Debug, PartialEq)]
pub enum Element {
/// Corresponse with nothing, ie the Nil byte
Empty,
/// A sequence o... | code_fim | hard | {
"lang": "rust",
"repo": "schallert/foundationdb-rs",
"path": "/foundationdb/src/tuple/element.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: schallert/foundationdb-rs path: /foundationdb/src/tuple/element.rs
t = Vec::<u8>::with_capacity(buf.len());
let mut offset = 0;
loop {
if offset >= buf.len() {
return Err(Error::EOF);
}
// is the null marker at the offset
if NIL.expect(buf[off... | code_fim | hard | {
"lang": "rust",
"repo": "schallert/foundationdb-rs",
"path": "/foundationdb/src/tuple/element.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JonnyBGod/rust-libp2p path: /futures-mutex/src/lib.rs
//! A Mutex for the Future(s)
//!
//! API is similar to [`futures::sync::BiLock`](https://docs.rs/futures/0.1.11/futures/sync/struct.BiLock.html)
//! However, it can be cloned into as many handles as desired.
//!
extern crate futures;
extern... | code_fim | hard | {
"lang": "rust",
"repo": "JonnyBGod/rust-libp2p",
"path": "/futures-mutex/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
#[test]
fn simple() {
let future = future::lazy(|| {
let lock1 = Arc::new(Mutex::new(1));
let lock2 = lock1.clone();
let lock3 = lock1.clone();
let mut guard = match lock1.poll_lock() {
Async::Ready(g) => g,
... | code_fim | hard | {
"lang": "rust",
"repo": "JonnyBGod/rust-libp2p",
"path": "/futures-mutex/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.vote.as_ref().and_then(|vote| vote.msg_type())
}
}
impl ConsensusMessage for Vote {
fn validate_basic(&self) -> Result<(), validate::Error> {
if self.msg_type().is_none() {
return Err(InvalidMessageType);
}
if self.height < 0 {
return E... | code_fim | hard | {
"lang": "rust",
"repo": "iqlusioninc/tmkms",
"path": "/src/amino_types/vote.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iqlusioninc/tmkms path: /src/amino_types/vote.rs
} else {
SignedVoteResponse {
vote: self.vote,
err: None,
}
};
rpc::Response::SignedVote(response)
}
}
impl ParseChainId for CanonicalVote {
fn parse_chain_... | code_fim | hard | {
"lang": "rust",
"repo": "iqlusioninc/tmkms",
"path": "/src/amino_types/vote.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iqlusioninc/tmkms path: /src/amino_types/vote.rs
lt<chain::Id, Error> {
self.chain_id.parse()
}
}
impl block::ParseHeight for CanonicalVote {
fn parse_block_height(&self) -> Result<block::Height, Error> {
block::Height::try_from(self.height)
}
}
impl CanonicalVote {... | code_fim | hard | {
"lang": "rust",
"repo": "iqlusioninc/tmkms",
"path": "/src/amino_types/vote.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub const EMBED_LEN_MAX: usize = 3;
pub const EMBED_FLAG: usize = FL_USER_1;
pub const EMBED_LEN_MASK: usize = FL_USER_4 | FL_USER_3;
pub const EMBED_LEN_SHIFT: usize = FL_USHIFT + 3;
}
extern "C" {
// void rb_ary_modify(VALUE ary)
pub fn rb_ary_modify(ary: VALUE);
// VALUE rb... | code_fim | hard | {
"lang": "rust",
"repo": "kubo/rosy",
"path": "/src/ruby_bindings/array.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kubo/rosy path: /src/ruby_bindings/array.rs
use std::ptr;
use super::{
prelude::*,
RBasic,
fl_type,
};
#[repr(C)]
#[derive(Clone, Copy)]
pub struct RArray {
pub basic: RBasic,
pub as_: RArrayAs,
}
impl RArray {
#[inline]
fn embed_len(&self) -> usize {
use ra... | code_fim | hard | {
"lang": "rust",
"repo": "kubo/rosy",
"path": "/src/ruby_bindings/array.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>definition;
pub const OPERATOR_COUNT: usize = 4;<|fim_prefix|>// repo: Gigoteur/UnicornConsole path: /unicorn/src/audio/instruments/fm/mod.rs
pub mod algorithm;
pub mod detune;
pub mod feedback;
pub mod fm_waveform;
pub mod frequency_multip<|fim_middle|>lier;
pub mod operator_definition;
pub mod patch_ | code_fim | easy | {
"lang": "rust",
"repo": "Gigoteur/UnicornConsole",
"path": "/unicorn/src/audio/instruments/fm/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Gigoteur/UnicornConsole path: /unicorn/src/audio/instruments/fm/mod.rs
pub mod algorithm;
pub mod detune;
pub mod feedba<|fim_suffix|>definition;
pub const OPERATOR_COUNT: usize = 4;<|fim_middle|>ck;
pub mod fm_waveform;
pub mod frequency_multiplier;
pub mod operator_definition;
pub mod patch_ | code_fim | medium | {
"lang": "rust",
"repo": "Gigoteur/UnicornConsole",
"path": "/unicorn/src/audio/instruments/fm/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nicolashahn/mcts-tic-tac-toe path: /src/agents/mcts_agent.rs
/// Monte Carlo tree search agent.
use std::collections::HashMap;
use std::f64;
use std::time::Instant;
use rand::seq::SliceRandom;
use rand::thread_rng;
use scoped_threadpool::Pool;
use crate::agents::BoardGameAgent;
use crate::gam... | code_fim | hard | {
"lang": "rust",
"repo": "nicolashahn/mcts-tic-tac-toe",
"path": "/src/agents/mcts_agent.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// If all the node's children have been expanded, set the node as fully expanded.
fn update_fully_expanded(&mut self) {
if self.children.len() == self.board.get_valid_moves().len()
&& self
.children
.values()
.filter(|&c| !c.is_f... | code_fim | hard | {
"lang": "rust",
"repo": "nicolashahn/mcts-tic-tac-toe",
"path": "/src/agents/mcts_agent.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let now = Instant::now();
let maybe_opp_move = self.get_opponents_last_move(board);
if let Some(opp_move) = maybe_opp_move {
self.update_with_opponents_move(opp_move, board);
}
// This is only guaranteed to create a new child while the expand() function... | code_fim | hard | {
"lang": "rust",
"repo": "nicolashahn/mcts-tic-tac-toe",
"path": "/src/agents/mcts_agent.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Entity of this window
let window_entity =
if let Some(entity) = winit_windows.get_window_entity(winit_window_id) {
entity
} else {
warn!(
"Skipped event {:... | code_fim | hard | {
"lang": "rust",
"repo": "clia/bevy",
"path": "/crates/bevy_winit/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clia/bevy path: /crates/bevy_winit/src/lib.rs
indowResized>,
window_close_requested: EventWriter<'w, WindowCloseRequested>,
window_scale_factor_changed: EventWriter<'w, WindowScaleFactorChanged>,
window_backend_scale_factor_changed: EventWriter<'w, WindowBackendScaleFactorChanged>,
... | code_fim | hard | {
"lang": "rust",
"repo": "clia/bevy",
"path": "/crates/bevy_winit/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hideki-okada/atcoder-rust path: /abc187/src/bin/b.rs
use proconio::{fastout, input};
#[allow(unused_macros)]
macro_rules! debug {
($($a:expr),*) => {
eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
}
}
#[fastout]
#[allow(non_snake_case)]
fn main() {
inp... | code_fim | medium | {
"lang": "rust",
"repo": "hideki-okada/atcoder-rust",
"path": "/abc187/src/bin/b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..N - 1 {
for j in i + 1..N {
let d_x = XY[i].0 - XY[j].0;
let d_y = XY[i].1 - XY[j].1;
if d_x == 0 {
continue;
}
if d_y.abs() <= d_x.abs() {
count += 1
}
}
}
print... | code_fim | medium | {
"lang": "rust",
"repo": "hideki-okada/atcoder-rust",
"path": "/abc187/src/bin/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> continue;
}
if d_y.abs() <= d_x.abs() {
count += 1
}
}
}
println!("{}", count)
}<|fim_prefix|>// repo: hideki-okada/atcoder-rust path: /abc187/src/bin/b.rs
use proconio::{fastout, input};
#[allow(unused_macros)]
macro_rules... | code_fim | hard | {
"lang": "rust",
"repo": "hideki-okada/atcoder-rust",
"path": "/abc187/src/bin/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Token {
pub fn get_position(&self) -> Position {
let pos = match self {
Token::Int(pos, _) |
Token::Float(pos, _) |
Token::String(pos, _) |
Token::StringInterp(pos, _) |
Token::Bool(pos, _) |
Token::Func(pos) |
... | code_fim | hard | {
"lang": "rust",
"repo": "kengorab/abra-lang",
"path": "/abra_core/src/lexer/tokens.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kengorab/abra-lang path: /abra_core/src/lexer/tokens.rs
use std::cmp::{max, min, Ordering};
#[derive(Debug, Clone, Eq, PartialEq, Ord)]
pub struct Position {
pub line: usize,
pub col: usize,
}
pub const POSITION_BOGUS: Position = Position { line: 0, col: 0 };
impl Position {
pub f... | code_fim | hard | {
"lang": "rust",
"repo": "kengorab/abra-lang",
"path": "/abra_core/src/lexer/tokens.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl TypeEnv {
/// Construct an empty type environment.
pub fn new() -> TypeEnv {
TypeEnv(HashMap::new())
}
/// Generalize creates a polytype
pub fn generalize(&self, ty: &Type) -> PolyType {
PolyType {
vars: ty.ftv().difference(&self.ftv()).cloned().collec... | code_fim | hard | {
"lang": "rust",
"repo": "coord-e/expressi",
"path": "/src/transform/type_infer/type_env.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> TypeEnv(self.iter().map(|(k, v)| (k.clone(), v.apply(s))).collect())
}
}
impl TypeEnv {
/// Construct an empty type environment.
pub fn new() -> TypeEnv {
TypeEnv(HashMap::new())
}
/// Generalize creates a polytype
pub fn generalize(&self, ty: &Type) -> PolyType {... | code_fim | hard | {
"lang": "rust",
"repo": "coord-e/expressi",
"path": "/src/transform/type_infer/type_env.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: coord-e/expressi path: /src/transform/type_infer/type_env.rs
//
// this code is based on https://github.com/nwoeanhinnogaehr/algorithmw-rust
//
// Copyright 2016 Noah Weninger
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was n... | code_fim | medium | {
"lang": "rust",
"repo": "coord-e/expressi",
"path": "/src/transform/type_infer/type_env.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // put the context into a waiting loop
pool.spawn(lazy(move || {
{
// temporarily split the context
let (immut_half, mut_half) = ctx.halves_mut();
// call the `on_start()` method of the actor
mut_half.actor_mut().... | code_fim | medium | {
"lang": "rust",
"repo": "f5xs-0000a/sekibanki",
"path": "/src/actor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: f5xs-0000a/sekibanki path: /src/actor.rs
use tokio_threadpool::Sender as TPSender;
use address::Addr;
use context::{Context, ContextImmutHalf};
use message::Message;
////////////////////////////////////////////////////////////////////////////////
/// Unit execution context that can send and p... | code_fim | hard | {
"lang": "rust",
"repo": "f5xs-0000a/sekibanki",
"path": "/src/actor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn on_message_exhaust(&mut self, _ctx: &ContextImmutHalf<Self>) {}
}
pub trait Handles<M>: Actor
where
M: Message<Self>,
{
type Response: Send;
fn handle(&mut self, msg: M, ctx: &ContextImmutHalf<Self>) -> Self::Response;
}
///////////////////////////////////////////////////////////////... | code_fim | hard | {
"lang": "rust",
"repo": "f5xs-0000a/sekibanki",
"path": "/src/actor.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.