text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>mod stream;
pub use self::stream::TcpStream;<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/mio-0.7.11/src/net/tcp/mod.rs
mod listener;
pub use self::listener::TcpListener;
<|fim_middle|>mod socket;
pub use self::socket::{TcpSocket, TcpKeepalive};
| code_fim | medium | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/mio-0.7.11/src/net/tcp/mod.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buffer = [0u8; 256];
for (instruction, ip) in decoder.instruction_iterator(CODE, 0) {
for (ty, val) in
formatter.tokenize_instruction(&instruction, &mut buffer[..], Some(ip), None)?
{
println!("token type: {}, value: {}", ty, val);
}
... | code_fim | medium | {
"lang": "rust",
"repo": "williballenthin/zydis-rs",
"path": "/examples/tokens.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: williballenthin/zydis-rs path: /examples/tokens.rs
extern crate zydis;
use zydis::*;
#[rustfmt::skip]
static CODE: &'static [u8] = &[
0x51, 0x8D, 0x45, 0xFF, 0x50, 0xFF, 0x75, 0x0C, 0xFF, 0x75, 0x08,
0xFF, 0x15, 0xA0, 0xA5, 0x48, 0x76, 0x85, 0xC0, 0x0F, 0x88, 0xFC,
0xDA, 0x02, 0x00... | code_fim | medium | {
"lang": "rust",
"repo": "williballenthin/zydis-rs",
"path": "/examples/tokens.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vinaychandra/winter path: /crates/winter_core/src/parse/modules/sections/custom_section.rs
use nom::{
bytes::complete::take_while, combinator::map, error::context, multi::length_value,
sequence::tuple,
};
use super::section_length_parser;
use crate::parse::{values::name_parser, Res};
<... | code_fim | medium | {
"lang": "rust",
"repo": "vinaychandra/winter",
"path": "/crates/winter_core/src/parse/modules/sections/custom_section.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct CustomSection<'a> {
pub name: &'a str,
pub data: &'a [u8],
}
pub fn custom_section_parser(input: &[u8]) -> Res<CustomSection> {
context(
"custom_section",
map(
length_value(
section_length_parser(0),
tuple... | code_fim | medium | {
"lang": "rust",
"repo": "vinaychandra/winter",
"path": "/crates/winter_core/src/parse/modules/sections/custom_section.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: michalseweryn/mpc-on-tcs path: /04.11/async-intro/examples/4/main.rs
use mini_redis::{Connection, Frame};
use tokio::net::{TcpListener, TcpStream};
#[tokio::main]
async fn main() {
let listener = TcpListener::bind("127.0.0.1:1729").await.unwrap();
loop {
let (socket, addr) = li... | code_fim | hard | {
"lang": "rust",
"repo": "michalseweryn/mpc-on-tcs",
"path": "/04.11/async-intro/examples/4/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> connection.write_frame(&v[1]).await.unwrap();
}
}
}<|fim_prefix|>// repo: michalseweryn/mpc-on-tcs path: /04.11/async-intro/examples/4/main.rs
use mini_redis::{Connection, Frame};
use tokio::net::{TcpListener, TcpStream};
<|fim_middle|>#[tokio::main]
async fn main() {
let lis... | code_fim | hard | {
"lang": "rust",
"repo": "michalseweryn/mpc-on-tcs",
"path": "/04.11/async-intro/examples/4/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 00mjk/stylist-rs path: /packages/stylist/tests/inline_display_impl.rs
use std::fmt::{Display, Formatter, Result};
enum Foo {
Bar,
}
impl Display for Foo {
fn fmt(&self, f: &mut Formatter) -> Result {
f.write_str("none")
}
}
impl Foo {
#[allow(dead_code, clippy::inherent_t... | code_fim | medium | {
"lang": "rust",
"repo": "00mjk/stylist-rs",
"path": "/packages/stylist/tests/inline_display_impl.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let style = stylist::style! {
display: ${Foo::Bar};
}
.unwrap();
let expected_result = format!(
r#".{cls} {{
display: none;
}}
"#,
cls = style.get_class_name()
);
assert_eq!(expected_result, style.get_style_str());
}<|fim_prefix|>// repo: 00mjk/stylist-r... | code_fim | medium | {
"lang": "rust",
"repo": "00mjk/stylist-rs",
"path": "/packages/stylist/tests/inline_display_impl.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lpc55/lpc55-pac path: /src/mrt0/irq_flag.rs
#[doc = "Register `IRQ_FLAG` reader"]
pub struct R(crate::R<IRQ_FLAG_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<IRQ_FLAG_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::... | code_fim | hard | {
"lang": "rust",
"repo": "lpc55/lpc55-pac",
"path": "/src/mrt0/irq_flag.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `GFLAG3` writer - Monitors the interrupt flag of TIMER3. See description of channel 0."]
pub struct GFLAG3_W<'a> {
w: &'a mut W,
}
impl<'a> GFLAG3_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
sel... | code_fim | hard | {
"lang": "rust",
"repo": "lpc55/lpc55-pac",
"path": "/src/mrt0/irq_flag.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `GFLAG0` writer - Monitors the interrupt flag of TIMER0."]
pub struct GFLAG0_W<'a> {
w: &'a mut W,
}
impl<'a> GFLAG0_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: GFLAG0_A) -> &'a mut W {
sel... | code_fim | hard | {
"lang": "rust",
"repo": "lpc55/lpc55-pac",
"path": "/src/mrt0/irq_flag.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tyehle/advent-of-code path: /2019/d10/src/main.rs
use num_complex::Complex;
use std::collections::HashSet;
use std::convert::TryInto;
use std::fs;
use std::f32;
fn read() -> HashSet<Complex<i32>> {
parse(fs::read_to_string("input.txt").unwrap())
}
fn parse(s: String) -> HashSet<Complex<i32... | code_fim | hard | {
"lang": "rust",
"repo": "tyehle/advent-of-code",
"path": "/2019/d10/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let complex = parse(
".#..##.###...#######
##.############..##.
.#.######.########.#
.###.#######.####.#.
#####.##.#.##.###.##
..#####..#.#########
####################
#.####....###.#.#.##
... | code_fim | hard | {
"lang": "rust",
"repo": "tyehle/advent-of-code",
"path": "/2019/d10/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut file = fs::File::create(file_path).expect("failed to create file");
file.write_all(bytes).expect("failed to write to file");
}<|fim_prefix|>// repo: rust-skia/rust-skia path: /skia-org/src/artifact.rs
use skia_safe::{Canvas, EncodedImageFormat, Surface};
use std::{fs, io::Write, path::Pat... | code_fim | medium | {
"lang": "rust",
"repo": "rust-skia/rust-skia",
"path": "/skia-org/src/artifact.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut file_path = path.join(name);
file_path.set_extension(ext);
let mut file = fs::File::create(file_path).expect("failed to create file");
file.write_all(bytes).expect("failed to write to file");
}<|fim_prefix|>// repo: rust-skia/rust-skia path: /skia-org/src/artifact.rs
use skia_saf... | code_fim | medium | {
"lang": "rust",
"repo": "rust-skia/rust-skia",
"path": "/skia-org/src/artifact.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-skia/rust-skia path: /skia-org/src/artifact.rs
use skia_safe::{Canvas, EncodedImageFormat, Surface};
use std::{fs, io::Write, path::Path};
<|fim_suffix|> let mut file_path = path.join(name);
file_path.set_extension(ext);
let mut file = fs::File::create(file_path).expect("failed... | code_fim | hard | {
"lang": "rust",
"repo": "rust-skia/rust-skia",
"path": "/skia-org/src/artifact.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joseluiscd/svgcode path: /src/model.rs
use lyon_path::Path;
pub struct Drawing {
paths: Vec<DrawingPath>
}
<|fim_suffix|> pub fn add_path(&mut self, path: Path, color: u8){
self.paths.push(DrawingPath{
color,
path
});
}
pub fn iter<'a>(&... | code_fim | medium | {
"lang": "rust",
"repo": "joseluiscd/svgcode",
"path": "/src/model.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Drawing{
pub fn new() -> Self {
Self{
paths: Vec::new()
}
}
pub fn add_path(&mut self, path: Path, color: u8){
self.paths.push(DrawingPath{
color,
path
});
}
pub fn iter<'a>(&'a self) -> std::slice::Iter<'a, Dra... | code_fim | medium | {
"lang": "rust",
"repo": "joseluiscd/svgcode",
"path": "/src/model.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> hr!();
dia!(choice!(
rpt!(
seq!(
choice!(
term!("Foo"),
seq!(opt!(term!("BarNoodle")), term!("NoodleBox"), term!("foo")),
term!("More"),
term!("42")
),
... | code_fim | hard | {
"lang": "rust",
"repo": "lukaslueg/railroad",
"path": "/examples/visuals.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dia!(stck!(
seq!(
term!("ALTER"),
term!("TABLE"),
opt!(seq!(term!("schema-name"), term!("."))),
term!("table-name")
),
lbox!(
choice!(
lbox!(
seq!(term!("RENAME"), term!("TO"), term!... | code_fim | hard | {
"lang": "rust",
"repo": "lukaslueg/railroad",
"path": "/examples/visuals.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lukaslueg/railroad path: /examples/visuals.rs
use std::fs;
use std::io::Write;
fn main() {
use railroad::*;
let mut f = fs::File::create("examples/visuals.html").unwrap();
macro_rules! hr {
() => {
f.write_all(b"<hr>").unwrap();
};
}
macro_rule... | code_fim | hard | {
"lang": "rust",
"repo": "lukaslueg/railroad",
"path": "/examples/visuals.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = source::save_caller(call.loc.clone(), heap);
heap.declare(
self.function.variables.iter(),
self.function.functions.iter(),
)?;
self.function.body.interpret(heap)
});
match result {
Ok(_) =... | code_fim | hard | {
"lang": "rust",
"repo": "EarlGray/language-incubator",
"path": "/js/slothjs/src/function.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EarlGray/language-incubator path: /js/slothjs/src/function.rs
use crate::prelude::*;
use crate::{
ast,
source,
Exception,
Heap,
Interpretable,
Interpreted,
JSObject,
JSRef,
JSResult,
JSValue,
Jump,
};
/// Call context information (e.g. arguments) for... | code_fim | hard | {
"lang": "rust",
"repo": "EarlGray/language-incubator",
"path": "/js/slothjs/src/function.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_export]
macro_rules! assert_state {
($results:ident, $order:tt, $expectation:expr) => {
assert_eq!(
$expectation,
*$results
.get(&ord($order))
.expect("Order should be in results"),
$order
);
};
}
/// Adju... | code_fim | hard | {
"lang": "rust",
"repo": "TedDriggs/diplomacy",
"path": "/diplomacy/tests/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TedDriggs/diplomacy path: /diplomacy/tests/util.rs
#![allow(dead_code)]
#![cfg(test)]
use diplomacy::geo;
use diplomacy::geo::{Coast, ProvinceKey, RegionKey};
use diplomacy::judge::{MappedMainOrder, MappedRetreatOrder, OrderState, Rulebook};
use std::collections::HashMap;
pub fn prov(s: &str) ... | code_fim | hard | {
"lang": "rust",
"repo": "TedDriggs/diplomacy",
"path": "/diplomacy/tests/util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn ord(s: &str) -> MappedMainOrder {
s.parse()
.unwrap_or_else(|_| panic!("'{}' should be a valid order", s))
}
pub fn retreat_ord(s: &str) -> MappedRetreatOrder {
s.parse()
.unwrap_or_else(|_| panic!("'{}' should be a valid order", s))
}
pub fn get_results(orders: Vec<&str>)... | code_fim | hard | {
"lang": "rust",
"repo": "TedDriggs/diplomacy",
"path": "/diplomacy/tests/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvidner/exercism-rust path: /collatz-conjecture/src/lib.rs
// return Ok(x) where x is the number of steps required to reach 1
pub fn collatz(n: u64) -> Result<u64, &'static str> {
if n == 0 {
return Err("The Collatz formula does not work on 0");
}
let mut count = 0;
let ... | code_fim | easy | {
"lang": "rust",
"repo": "mvidner/exercism-rust",
"path": "/collatz-conjecture/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if n % 2 == 0 {
n / 2
} else {
3 * n + 1
}
}<|fim_prefix|>// repo: mvidner/exercism-rust path: /collatz-conjecture/src/lib.rs
// return Ok(x) where x is the number of steps required to reach 1
pub fn collatz(n: u64) -> Result<u64, &'static str> {
if n == 0 {
return... | code_fim | medium | {
"lang": "rust",
"repo": "mvidner/exercism-rust",
"path": "/collatz-conjecture/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_dimensions(&self) -> (u32, u32) {
(self.texture.get_width(), self.texture.get_height().unwrap())
}
pub fn glium_texture(&self) -> &Texture2d {
&self.texture
}
}<|fim_prefix|>// repo: Hakon/jamkit path: /src/texture.rs
// Copyright 2015 The Athena Developers.
//... | code_fim | medium | {
"lang": "rust",
"repo": "Hakon/jamkit",
"path": "/src/texture.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hakon/jamkit path: /src/texture.rs
// Copyright 2015 The Athena Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/license... | code_fim | hard | {
"lang": "rust",
"repo": "Hakon/jamkit",
"path": "/src/texture.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct Texture {
texture: Texture2d
}
impl Texture {
pub fn load(graphics: &Graphics, path: &str) -> Texture {
let image = image::open(&Path::new(path)).unwrap();
let texture = Texture2d::new(graphics.glium_display(), image);
Texture {
texture: texture,
... | code_fim | medium | {
"lang": "rust",
"repo": "Hakon/jamkit",
"path": "/src/texture.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RoastVeg/wlrusts path: /src/types/seat/wlr_seat.rs
T_TRANSFORM_FLIPPED: wl_output_transform = 4;
pub const WL_OUTPUT_TRANSFORM_270: wl_output_transform = 3;
pub const WL_OUTPUT_TRANSFORM_180: wl_output_transform = 2;
pub const WL_OUTPUT_TRANSFORM_90: wl_output_transform = 1;
pub const WL_OUTPUT_... | code_fim | hard | {
"lang": "rust",
"repo": "RoastVeg/wlrusts",
"path": "/src/types/seat/wlr_seat.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rn 0 as *mut wlr_seat }
// pointer state
(*seat).pointer_state.seat = seat;
wl_list_init(&mut (*seat).pointer_state.surface_destroy.link);
let mut pointer_grab: *mut wlr_seat_pointer_grab =
calloc(1i32 as libc::c_ulong,
::std::mem::size_of::<wlr_seat_pointer_grab>() ... | code_fim | hard | {
"lang": "rust",
"repo": "RoastVeg/wlrusts",
"path": "/src/types/seat/wlr_seat.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
pub type size_t = libc::c_ulong;
pub type __int32_t = libc::c_int;
pub type __uint32_t = libc::c_uint;
pub type __time_t = libc::c_long;
pub type __syscall_slong_t = libc::c_long;
#[derive ( Copy, Clone )]
#[repr(C)]
pub struct timespec {
pub tv_sec: __time_t,
pub tv_nsec: __syscall_slong_t,
}
p... | code_fim | hard | {
"lang": "rust",
"repo": "RoastVeg/wlrusts",
"path": "/src/types/seat/wlr_seat.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: upspeak/upspeak path: /src/flow/mod.rs
mod component;
mod network;
mod packet;
mod port;
mod p<|fim_suffix|>b use port::{InPort, OutPort};
pub use process::Process;<|fim_middle|>rocess;
pub use component::{Component, ComponentMustRun};
pub use network::Network;
pub use packet::Packet;
pu | code_fim | medium | {
"lang": "rust",
"repo": "upspeak/upspeak",
"path": "/src/flow/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: upspeak/upspeak path: /src/flow/mod.rs
mod component;
mod network;
mod packet;
mod port;
mod process;
pub use component::{Component, ComponentMustRun<|fim_suffix|>b use port::{InPort, OutPort};
pub use process::Process;<|fim_middle|>};
pub use network::Network;
pub use packet::Packet;
pu | code_fim | easy | {
"lang": "rust",
"repo": "upspeak/upspeak",
"path": "/src/flow/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>b use port::{InPort, OutPort};
pub use process::Process;<|fim_prefix|>// repo: upspeak/upspeak path: /src/flow/mod.rs
mod component;
mod network;
mod packet;
mod port;
mod p<|fim_middle|>rocess;
pub use component::{Component, ComponentMustRun};
pub use network::Network;
pub use packet::Packet;
pu | code_fim | medium | {
"lang": "rust",
"repo": "upspeak/upspeak",
"path": "/src/flow/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.points_.push(pt);
}
} else {
self.points_.push(point);
}
Result::Ok(())
}
pub fn remove(&mut self) -> Option<Point> {
self.points_.pop()
}
pub fn insertion_point(&self, point: &Point) -> Option<usize> {
... | code_fim | hard | {
"lang": "rust",
"repo": "d-becker/spider",
"path": "/spider_backend/src/model/rectilinear/path/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: d-becker/spider path: /spider_backend/src/model/rectilinear/path/mod.rs
use std::borrow::Borrow;
use super::{Line, LineIntersection};
use crate::iter::skip_last::SkipLastIterator;
use crate::model::point::Point;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Path {
points_: Vec<Point>,
... | code_fim | hard | {
"lang": "rust",
"repo": "d-becker/spider",
"path": "/spider_backend/src/model/rectilinear/path/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod test {
use super::*;
use crate::environment::TestEnvironmentBuilder;
#[test]
fn should_get_valid() {
let mut builder = TestEnvironmentBuilder::new();
builder
.add_remote_file(
"https://plugins.dprint.dev/plugin/latest.json",
r#"{ "schemaVersion": 1, ... | code_fim | hard | {
"lang": "rust",
"repo": "dprint/dprint",
"path": "/crates/dprint/src/plugins/repo/read_update_url.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn should_get_valid() {
let mut builder = TestEnvironmentBuilder::new();
builder
.add_remote_file(
"https://plugins.dprint.dev/plugin/latest.json",
r#"{ "schemaVersion": 1, "url": "url", "version": "version" }"#,
)
.add_remote_file(
"https://pl... | code_fim | hard | {
"lang": "rust",
"repo": "dprint/dprint",
"path": "/crates/dprint/src/plugins/repo/read_update_url.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dprint/dprint path: /crates/dprint/src/plugins/repo/read_update_url.rs
use anyhow::anyhow;
use anyhow::bail;
use anyhow::Result;
use jsonc_parser::parse_to_value;
use jsonc_parser::JsonValue;
use url::Url;
use crate::environment::UrlDownloader;
use crate::plugins::PluginSourceReference;
use cra... | code_fim | hard | {
"lang": "rust",
"repo": "dprint/dprint",
"path": "/crates/dprint/src/plugins/repo/read_update_url.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a = AtomicCell::new(Foo::new(5));
assert_eq!(a.swap(Foo::new(6)), Foo::new(5));
assert_eq!(a.swap(Foo::new(1)), Foo::new(6));
assert_eq!(CNT.load(SeqCst), 1);
a.store(Foo::new(2));
assert_eq!(CNT.load(SeqCst), 1);
assert_eq!(a.swap(Foo::default()), Foo::new(2));
asse... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/crossbeam-utils-0.7.2/tests/atomic_cell.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn garbage_padding() {
#[derive(Copy, Clone, Eq, PartialEq)]
struct Object {
a: i64,
b: i32,
}
let cell = AtomicCell::new(Object { a: 0, b: 0 });
let _garbage = [0xfe, 0xfe, 0xfe, 0xfe, 0xfe]; // Needed
let next = Object { a: 0, b: 0 };
let prev = cell... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/crossbeam-utils-0.7.2/tests/atomic_cell.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/crossbeam-utils-0.7.2/tests/atomic_cell.rs
extern crate crossbeam_utils;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::SeqCst;
use crossbeam_utils::atomic::AtomicCell;
#[test]
fn is_lock_free() {
struct UsizeWra... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/crossbeam-utils-0.7.2/tests/atomic_cell.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ray: Ray<f32> = ray.inner_into();
let dis = match test {
RayCastResult::Hit((_, dis)) => dis.into_inner(),
RayCastResult::NoHit => 800.0,
};
let end = ray.point_at_tval(dis);
canvas
.lines(2.0)
.add(ray.point.in... | code_fim | hard | {
"lang": "rust",
"repo": "tiby312/dinotree_alg",
"path": "/dinotree_alg_demo/src/demos/demo_raycast_f32_debug.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ray.inner_into::<f32>()
.cast_to_rect(d.get().as_ref())
.map(|a| f32n(a))
},
dim,
);
rects
.send_and_uniforms(canvas)
.with_color([4.0, 0.0, 0.0, 0.4]... | code_fim | hard | {
"lang": "rust",
"repo": "tiby312/dinotree_alg",
"path": "/dinotree_alg_demo/src/demos/demo_raycast_f32_debug.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tiby312/dinotree_alg path: /dinotree_alg_demo/src/demos/demo_raycast_f32_debug.rs
use crate::support::prelude::*;
use axgeom::Ray;
#[derive(Copy, Clone, Debug)]
pub struct Bot;
pub fn make_demo(dim: Rect<F32n>, canvas: &mut SimpleCanvas) -> Demo {
let ii: Vec<_> = dists::rand2_iter(dim.in... | code_fim | hard | {
"lang": "rust",
"repo": "tiby312/dinotree_alg",
"path": "/dinotree_alg_demo/src/demos/demo_raycast_f32_debug.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: geneidy/interbtc path: /crates/fee/src/ext.rs
#[cfg(test)]
use mocktopus::macros::mockable;
<|fim_suffix|> pub fn ensure_parachain_status_not_shutdown<T: crate::Config>() -> Result<(), DispatchError> {
<security::Pallet<T>>::ensure_parachain_status_not_shutdown()
}
}<|fim_middle|... | code_fim | medium | {
"lang": "rust",
"repo": "geneidy/interbtc",
"path": "/crates/fee/src/ext.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut server = hmac_server::start(key)?;
let result = hmac_client::run();
server.close().context("failed to close connection")?;
result
}<|fim_prefix|>// repo: passchaos/cryptopals-rust path: /challenges/src/set4/challenge32.rs
use super::hmac_client;
use super::hmac_server;
use rand;... | code_fim | hard | {
"lang": "rust",
"repo": "passchaos/cryptopals-rust",
"path": "/challenges/src/set4/challenge32.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: passchaos/cryptopals-rust path: /challenges/src/set4/challenge32.rs
use super::hmac_client;
use super::hmac_server;
use rand;
use rand::Rng;
<|fim_suffix|>pub fn run() -> Result<(), Error> {
println!("Challenge 32: takes about three minutes, pleases wait ...");
let mut rng = rand::thre... | code_fim | easy | {
"lang": "rust",
"repo": "passchaos/cryptopals-rust",
"path": "/challenges/src/set4/challenge32.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Input file to load a generation.
#[structopt(short = "i", long = "input", parse(from_os_str), default_value = "")]
pub input: PathBuf,
/// Output file to save a generation.
#[structopt(
short = "o",
long = "output",
parse(from_os_str),
default_value... | code_fim | hard | {
"lang": "rust",
"repo": "luizdepra/rust-life",
"path": "/src/configuration.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: luizdepra/rust-life path: /src/configuration.rs
use std::path::PathBuf;
use structopt::StructOpt;
/// The rust-life command line configuration.
#[derive(StructOpt, Debug)]
#[structopt(name = "rust-life")]
pub struct Config {
/// World width.
#[structopt(short = "w", long = "width", def... | code_fim | medium | {
"lang": "rust",
"repo": "luizdepra/rust-life",
"path": "/src/configuration.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Output file to save a generation.
#[structopt(
short = "o",
long = "output",
parse(from_os_str),
default_value = "out.rl"
)]
pub output: PathBuf,
}<|fim_prefix|>// repo: luizdepra/rust-life path: /src/configuration.rs
use std::path::PathBuf;
use struct... | code_fim | hard | {
"lang": "rust",
"repo": "luizdepra/rust-life",
"path": "/src/configuration.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> vkGetDisplayModePropertiesKHR(
physicalDevice: VkPhysicalDevice,
display: VkDisplayKHR,
pPropertyCount: *mut u32,
pProperties: *mut VkDisplayModePropertiesKHR
) -> VkResult,
vkCreateDisplayModeKHR(
physicalDevice: VkPhysicalDevice,
display: VkDi... | code_fim | hard | {
"lang": "rust",
"repo": "hodasemi/Context",
"path": "/vulkan-sys/src/functions/khr/instance_wsi.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hodasemi/Context path: /vulkan-sys/src/functions/khr/instance_wsi.rs
use crate::load_function_ptrs;
use crate::prelude::*;
use std::os::raw::c_void;
load_function_ptrs!(InstanceWSIFunctions, {
vkGetPhysicalDeviceSurfaceSupportKHR(
physicalDevice: VkPhysicalDevice,
queueFami... | code_fim | hard | {
"lang": "rust",
"repo": "hodasemi/Context",
"path": "/vulkan-sys/src/functions/khr/instance_wsi.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let serialized_action = circuit_abandon
.write_to_bytes()
.expect("Unable to serialize `CircuitAbandon`");
let hashed_bytes = hash(MessageDigest::sha512(), &serialized_action)
.expect("Unable to hash `CircuitAbandon` bytes");
let mut header = CircuitManagementPayload_H... | code_fim | hard | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/splinterd/tests/admin/payload.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cargill/splinter path: /splinterd/tests/admin/payload.rs
// Copyright 2018-2022 Cargill Incorporated
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http... | code_fim | hard | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/splinterd/tests/admin/payload.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if (smoothing.current - smoothing.heading).norm() < 1.0e-5 {
commands.remove_component::<Smoothing>(*entity);
}
})
})
}<|fim_prefix|>// repo: nylonblonde/wolf-gang path: /wolf_gang/src/systems/smoothing.rs
use legion::*;
type Vector... | code_fim | hard | {
"lang": "rust",
"repo": "nylonblonde/wolf-gang",
"path": "/wolf_gang/src/systems/smoothing.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nylonblonde/wolf-gang path: /wolf_gang/src/systems/smoothing.rs
use legion::*;
type Vector3D = nalgebra::Vector3<f32>;
//TODO: Make this generic so we can smooth out floats, other types, etc
pub struct Smoothing {
pub current: Vector3D,
pub heading: Vector3D,
pub speed: f32
}
<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "nylonblonde/wolf-gang",
"path": "/wolf_gang/src/systems/smoothing.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn read_page(&mut self, page_id: PageId, data: &mut PageData) -> io::Result<()> {
*data = self.pages[page_id.0 as usize];
Ok(())
}
async fn allocate_page(&mut self) -> io::Result<PageId> {
let id = PageId(self.pages.len().try_into().expect("PageId overflow"));
... | code_fim | hard | {
"lang": "rust",
"repo": "zyla/dbstuff",
"path": "/buffer-pool/src/disk_manager_mem.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[async_trait]
impl DiskManager for DiskManagerMem {
async fn write_page(&mut self, page_id: PageId, data: &PageData) -> io::Result<()> {
self.pages[page_id.0 as usize] = *data;
Ok(())
}
async fn read_page(&mut self, page_id: PageId, data: &mut PageData) -> io::Result<()> {
... | code_fim | medium | {
"lang": "rust",
"repo": "zyla/dbstuff",
"path": "/buffer-pool/src/disk_manager_mem.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zyla/dbstuff path: /buffer-pool/src/disk_manager_mem.rs
use crate::disk_manager::{DiskManager, PageData, PageId, PAGE_SIZE};
use async_trait::async_trait;
use std::convert::TryInto;
use std::io;
pub struct DiskManagerMem {
pages: Vec<PageData>,
}
impl DiskManagerMem {
pub fn new() -> S... | code_fim | hard | {
"lang": "rust",
"repo": "zyla/dbstuff",
"path": "/buffer-pool/src/disk_manager_mem.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/chumsky path: /src/error.rs
use super::*;
use std::{collections::HashSet, hash::Hash};
#[cfg(feature = "ahash")]
type RandomState = ahash::RandomState;
#[cfg(not(feature = "ahash"))]
type RandomState = std::collections::hash_set::RandomState;
/// A trait that describes parser error typ... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/chumsky",
"path": "/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self.expected.len() {
0 => write!(f, "but end of input was expected")?,
1 => write!(
f,
"but {} was expected",
self.expected.iter().next().unwrap()
)?,
_ => write!(
f,
... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/chumsky",
"path": "/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn handler_result(_: Result<MyJson, MyJsonRejection>) {}
#[derive(FromRequest, Deserialize)]
#[from_request(
via(axum::extract::Json),
rejection(MyJsonRejection),
)]
#[serde(transparent)]
struct MyJson(HashMap<String, String>);
struct MyJsonRejection {}
impl From<JsonRejection> for MyJson... | code_fim | medium | {
"lang": "rust",
"repo": "tokio-rs/axum",
"path": "/axum-macros/tests/from_request/pass/override_rejection_non_generic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl IntoResponse for MyJsonRejection {
fn into_response(self) -> Response {
todo!()
}
}<|fim_prefix|>// repo: tokio-rs/axum path: /axum-macros/tests/from_request/pass/override_rejection_non_generic.rs
use axum::{
extract::rejection::JsonRejection,
response::{IntoResponse, Respons... | code_fim | hard | {
"lang": "rust",
"repo": "tokio-rs/axum",
"path": "/axum-macros/tests/from_request/pass/override_rejection_non_generic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tokio-rs/axum path: /axum-macros/tests/from_request/pass/override_rejection_non_generic.rs
use axum::{
extract::rejection::JsonRejection,
response::{IntoResponse, Response},
routing::get,
Router,
};
use axum_macros::FromRequest;
use std::collections::HashMap;
use serde::Deseriali... | code_fim | hard | {
"lang": "rust",
"repo": "tokio-rs/axum",
"path": "/axum-macros/tests/from_request/pass/override_rejection_non_generic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as _
}
}
#[doc = "Reader of field `SV5_CFG`"]
pub type SV5_CFG_R = crate::R<u8, SV5_CFG_A>;
impl SV5_CFG_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<u8, SV5_CFG_A> {
use crate::Variant::*;
match sel... | code_fim | hard | {
"lang": "rust",
"repo": "Shock-1/teensy4-rs",
"path": "/imxrt1062-pac/imxrt1062-snvs/src/hpsvcr.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Shock-1/teensy4-rs path: /imxrt1062-pac/imxrt1062-snvs/src/hpsvcr.rs
0 Security Violation Input\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum SV0_CFG_A {
#[doc = "0: Security Violation 0 is a non-fatal violation"]
SV0_CFG_0 = 0,
#[doc = "1: Security Violat... | code_fim | hard | {
"lang": "rust",
"repo": "Shock-1/teensy4-rs",
"path": "/imxrt1062-pac/imxrt1062-snvs/src/hpsvcr.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Shock-1/teensy4-rs path: /imxrt1062-pac/imxrt1062-snvs/src/hpsvcr.rs
iant: SV0_CFG_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Security Violation 0 is a non-fatal violation"]
#[inline(always)]
pub fn sv0_cfg_0(self) -> &'a mut W {
... | code_fim | hard | {
"lang": "rust",
"repo": "Shock-1/teensy4-rs",
"path": "/imxrt1062-pac/imxrt1062-snvs/src/hpsvcr.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut msg = parser::Parser::parse(&req);
msg.header.answer_count = 1;
msg.answers.push(
Answer {
name: "www.jarretthelton.dev".to_string(),
qtype: 1,
qclass: 1,
tty: 50,
rd_len: 4,
... | code_fim | hard | {
"lang": "rust",
"repo": "JayHelton/saymyname",
"path": "/src/lib/udp/udp_service.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JayHelton/saymyname path: /src/lib/udp/udp_service.rs
use std::{pin::Pin, task::Poll};
use tower_service::Service;
use futures::Future;
use crate::lib::dns_query_parser::{answer::Answer, parser};
<|fim_suffix|>impl Service<Vec<u8>> for UdpService {
type Response = Vec<u8>;
type Error = ... | code_fim | medium | {
"lang": "rust",
"repo": "JayHelton/saymyname",
"path": "/src/lib/udp/udp_service.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_name(&self) -> &String
{
&self.name
}
pub fn get_bounding_box(&self) -> &BoundingBox
{
&self.bounding_box
}
pub fn get_transform(&self) -> Matrix4<f32>
{
self.transform
}
pub fn check_hit(&self, ray: &Ray) -> Option<(Hit, &dyn Material)>
{
if self.ray_previously_visited(ra... | code_fim | hard | {
"lang": "rust",
"repo": "DalePutnam/aurora",
"path": "/src/object.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DalePutnam/aurora path: /src/object.rs
use std::borrow::Borrow;
use std::cell::Cell;
use std::fmt;
use std::sync::Arc;
use na::Matrix4;
use primitives::BoundingBox;
use primitives::Primitive;
use shading::Material;
use thread_local::ThreadLocal;
use Hit;
use Ray;
<|fim_suffix|> pub fn check_hi... | code_fim | hard | {
"lang": "rust",
"repo": "DalePutnam/aurora",
"path": "/src/object.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn largest_palindrome_product() -> usize {
let mut x: usize = 0;
let mut sol: usize = 0;
for i in 100..999 {
for j in 100..999{
x = i * j;
if x.to_string() == x.to_string().chars().rev().collect::<String>() && x > sol{
sol = x
}
... | code_fim | medium | {
"lang": "rust",
"repo": "jmrada14/projectEuler",
"path": "/rust/largest_palindrome_product.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jmrada14/projectEuler path: /rust/largest_palindrome_product.rs
// Problem:
// A palindromic number reads the same both ways. The largest palindrome made from the product
// of two 2-digit numbers is 9009 = 91 × 99.
// Find the largest palindrome made from the product of two 3-digit numbers.
<... | code_fim | medium | {
"lang": "rust",
"repo": "jmrada14/projectEuler",
"path": "/rust/largest_palindrome_product.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}",largest_palindrome_product());
// 906609
}
pub fn largest_palindrome_product() -> usize {
let mut x: usize = 0;
let mut sol: usize = 0;
for i in 100..999 {
for j in 100..999{
x = i * j;
if x.to_string() == x.to_string().chars().rev().colle... | code_fim | medium | {
"lang": "rust",
"repo": "jmrada14/projectEuler",
"path": "/rust/largest_palindrome_product.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // this should be included when you run *all* tests
// or when you run `cargo test integration`
// or when you run `cargo test ex`
assert_eq!(4, mylib::add_two(2));
}<|fim_prefix|>// repo: doctorwidget/rust_book_examples path: /17_testing/tests/integration_tests.rs
/**
* A sample integra... | code_fim | medium | {
"lang": "rust",
"repo": "doctorwidget/rust_book_examples",
"path": "/17_testing/tests/integration_tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doctorwidget/rust_book_examples path: /17_testing/tests/integration_tests.rs
/**
* A sample integration test file.
*
* There's nothing special about the *name* of this file, but the *location*
* is highly significant by convention. EVERY file inside the `{root}/tests`
* directory is trea... | code_fim | medium | {
"lang": "rust",
"repo": "doctorwidget/rust_book_examples",
"path": "/17_testing/tests/integration_tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Atul9/viewimg path: /src/utils.rs
use exr::image::rgba::{Image, Pixels};
pub fn extract_exr_data(image: &Image) -> Vec<u8> {
let (width, height) = (image.resolution.0, image.resolution.1);
let mut exr_data = vec![0u8; width as usize * height as usize * 3];
for i in 0..(width * hei... | code_fim | medium | {
"lang": "rust",
"repo": "Atul9/viewimg",
"path": "/src/utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn clamp_f32(value: f32, lower_bound: f32, upper_bound: f32) -> f32 {
let minimum = value.max(lower_bound);
let maximum = value.min(upper_bound);
minimum.min(maximum)
}
pub fn clamp_rgb(value: f32) -> f32 { value.min(255.0).max(0.0) }
pub fn gamma_correct(luminance: f32, gamma: f32) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "Atul9/viewimg",
"path": "/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_export] macro_rules! impl_changeable_body{
(on_changed $model_name:ident (&mut $arg:ident) $body:expr) => {
fn on_changed($arg: &mut $model_name) {
$body
}
};
}
//$(do $action_name => $action:expr,)*
#[macro_export] macro_rules! impl_changeable_struct{
($change_name:ident[$signal_name:... | code_fim | hard | {
"lang": "rust",
"repo": "yokljo/modelone",
"path": "/modelone/src/model.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yokljo/modelone path: /modelone/src/model.rs
ST) {
(self.watcher_fn)(signal);
}
}
/// A watcher which collects signals in a Vec. Useful for debugging.
pub struct SpyWatcher<ST> {
pub signals: Vec<ST>,
}
impl<ST> SpyWatcher<ST> {
pub fn new() -> SpyWatcher<ST> {
SpyWatcher {
signals: ... | code_fim | hard | {
"lang": "rust",
"repo": "yokljo/modelone",
"path": "/modelone/src/model.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[allow(non_camel_case_types)]
#[derive(Debug, Clone, PartialEq)]
pub enum $signal_name {
$(
$field_name(<$change_type as $crate::model::Change>::SignalType),
)*
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, PartialEq)]
pub enum $change_name {
$($field_name($change... | code_fim | hard | {
"lang": "rust",
"repo": "yokljo/modelone",
"path": "/modelone/src/model.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: louwaque/l-compilator path: /src/token.rs
use std::fmt;
#[derive(Debug, PartialEq, Clone)]
pub enum Token {
Number(u32),
Id(String),
Comma,
Semicolon,
// Types
IntegerType,
// Predefined functions
ReadFunction,
WriteFunction,
<|fim_suffix|> // Operators... | code_fim | hard | {
"lang": "rust",
"repo": "louwaque/l-compilator",
"path": "/src/token.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(cl) = &self.consistency_level {
request.insert_headers(cl);
}
request.set_body(bytes::Bytes::new());
let response = self
.client
.pipeline()
.send(
self.context.c... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/azure-sdk-for-rust",
"path": "/sdk/data_cosmos/src/operations/get_user.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Azure/azure-sdk-for-rust path: /sdk/data_cosmos/src/operations/get_user.rs
use crate::{prelude::*, resources::user::UserResponse as GetUserResponse};
operation! {
GetUser,
client: UserClient,
?consistency_level: ConsistencyLevel
}
<|fim_suffix|> if let Some(cl) = &self.c... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/azure-sdk-for-rust",
"path": "/sdk/data_cosmos/src/operations/get_user.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn write_list<W: Write>(w: &mut W, items: &[impl AsRef<str>]) -> Result<(), W::Error> {
Ok(for i in items {
w.write(i.as_ref())?;
})
}
pub fn write_list_by<W: Write>(
w: &mut W,
sep: impl AsRef<str>,
items: &[impl AsRef<str>],
) -> Result<(), W::Error> {
let mut first ... | code_fim | hard | {
"lang": "rust",
"repo": "ecreeth/hhvm",
"path": "/hphp/hack/src/hhbc/write.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ecreeth/hhvm path: /hphp/hack/src/hhbc/write.rs
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
#![allow(unused_variables)]
#![allow(dead_code)]
use std::{
... | code_fim | hard | {
"lang": "rust",
"repo": "ecreeth/hhvm",
"path": "/hphp/hack/src/hhbc/write.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yinlei/tdengine path: /src/lib.rs
extern crate libc;
extern crate net2;
extern crate crypto;
extern crate rustc_serialize;
extern crate mysql;
extern crate tiny_http;
extern crate sys_info;
extern crate url;
extern crate time;
extern crate rusqlite;
extern crate td_rlua;
extern crate td_proto_r... | code_fim | medium | {
"lang": "rust",
"repo": "yinlei/tdengine",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ojii/aoc2019 path: /src/render.rs
use itertools::Itertools;
use std::collections::HashMap;
use std::fmt::Display;
pub fn render<B, I: Iterator<Item = ((i64, i64), B)>>(data: I, background: B) -> String
where
B: Display,
{
let coords: HashMap<(i64, i64), B> = data.collect();
let (min... | code_fim | medium | {
"lang": "rust",
"repo": "ojii/aoc2019",
"path": "/src/render.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>option()
.unwrap();
let (min_y, max_y) = coords
.keys()
.map(|&(_, y)| y)
.minmax()
.into_option()
.unwrap();
(min_y..=max_y)
.map(|y| {
(min_x..=max_x)
.map(|x| coords.get(&(x, y)).unwrap_or(&background))
... | code_fim | medium | {
"lang": "rust",
"repo": "ojii/aoc2019",
"path": "/src/render.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>_y)
.map(|y| {
(min_x..=max_x)
.map(|x| coords.get(&(x, y)).unwrap_or(&background))
.join("")
})
.join("\n")
}<|fim_prefix|>// repo: ojii/aoc2019 path: /src/render.rs
use itertools::Itertools;
use std::collections::HashMap;
use std::fmt:... | code_fim | medium | {
"lang": "rust",
"repo": "ojii/aoc2019",
"path": "/src/render.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn map_msg(self, f: impl FnOnce(Msg) -> OtherMsg + 'static + Clone) -> Self::SelfWithOtherMs {
Item {
content: self.content.map_msg(f),
id: self.id,
order: self.order,
grow: self.grow,
shrink: self.shrink,
basis: self.basi... | code_fim | hard | {
"lang": "rust",
"repo": "MuhannadAlrusayni/savory",
"path": "/elements/src/layout/flex/item.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<Msg: 'static, OtherMsg: 'static> MessageMapper<Msg, OtherMsg> for Item<Msg> {
type SelfWithOtherMs = Item<OtherMsg>;
fn map_msg(self, f: impl FnOnce(Msg) -> OtherMsg + 'static + Clone) -> Self::SelfWithOtherMs {
Item {
content: self.content.map_msg(f),
id: sel... | code_fim | hard | {
"lang": "rust",
"repo": "MuhannadAlrusayni/savory",
"path": "/elements/src/layout/flex/item.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MuhannadAlrusayni/savory path: /elements/src/layout/flex/item.rs
use crate::id::Id;
use derive_rich::Rich;
use savory::prelude::*;
use savory_style::{box_align::*, flexbox::*, prelude::*, values as val};
#[derive(Rich)]
pub struct Item<Msg> {
#[rich(write)]
pub id: Option<Id>,
#[ri... | code_fim | hard | {
"lang": "rust",
"repo": "MuhannadAlrusayni/savory",
"path": "/elements/src/layout/flex/item.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A Cache of fallback depth textures that uses the sample count as a key
///
/// # WARNING
/// Depth images are never initialized with data, therefore,
/// you shouldn't sample them before writing data to them first.
#[derive(Resource, Deref, DerefMut, Default)]
pub struct FallbackImageDepthCache(HashMa... | code_fim | hard | {
"lang": "rust",
"repo": "bevyengine/bevy",
"path": "/crates/bevy_render/src/texture/fallback_image.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bevyengine/bevy path: /crates/bevy_render/src/texture/fallback_image.rs
use crate::{render_resource::*, texture::DefaultImageSampler};
use bevy_derive::{Deref, DerefMut};
use bevy_ecs::{
prelude::{FromWorld, Res, ResMut},
system::{Resource, SystemParam},
};
use bevy_math::Vec2;
use bevy_... | code_fim | hard | {
"lang": "rust",
"repo": "bevyengine/bevy",
"path": "/crates/bevy_render/src/texture/fallback_image.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.