text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> let row = many1(cell);
let grid = separated_list1(line_ending, row);
map_res(grid, |rows: Vec<Vec<Cell>>| {
let height = rows.len();
if height < 3 || height > 64 {
return Err(anyhow!("map height must be in 3..=64 but is {}", height));
}
let width = r... | code_fim | hard | {
"lang": "rust",
"repo": "Aidiakapi/advent-of-code-2016",
"path": "/src/day24.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Dot product between two 3D vectors
#[inline(always)]
fn dot(m: Vector3D, n: Vector3D) -> Float {
m[0] * n[0] + m[1] * n[1] + m[2] * n[2]
}
/// Cross product between two 3D vectors
#[inline(always)]
fn cross(m: Vector3D, n: Vector3D) -> Vector3D {
[
m[1] * n[2] - m[2] * n[1],
m... | code_fim | hard | {
"lang": "rust",
"repo": "TianyiShi2001/dihedral",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
const P0: Point3D = [24.969, 13.428, 30.692]; // N
const P1: Point3D = [24.044, 12.661, 29.808]; // CA
const P2: Point3D = [22.785, 13.482, 29.543]; // C
const P3: Point3D = [21.951, 13.670, 30.431]; // O
const P4: Point3D = [23.672, 11.328,... | code_fim | hard | {
"lang": "rust",
"repo": "TianyiShi2001/dihedral",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TianyiShi2001/dihedral path: /src/lib.rs
//! # Dihedral
//!
//! [](https://crates.io/crates/dihedral)
//! [](https://crates.io/crates/dihedral)
//! [ {
self.path.ops.push(PathOp::Close)
}
/// Adds an arc approximated by quadratic beziers with center `x`, `y`
/// and radius `r` starting at `start_angle` and sweeping by `sweep_angle`.
/// For a positive `sweep_angle`... | code_fim | hard | {
"lang": "rust",
"repo": "jrmuizel/raqote",
"path": "/src/path_builder.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jrmuizel/raqote path: /src/path_builder.rs
use lyon_geom::Angle;
use lyon_geom::Arc;
use lyon_geom::CubicBezierSegment;
use lyon_geom::QuadraticBezierSegment;
use crate::{Point, Transform, Vector};
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum Winding {
EvenOdd,
NonZero,
}
#[deriv... | code_fim | hard | {
"lang": "rust",
"repo": "jrmuizel/raqote",
"path": "/src/path_builder.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // cross product/perp dot product lets us know which side of the line we're on
let cross = dx * (self.y - y1) - dy * (self.x - x1);
if cross == 0. {
self.on_edge = true;
} else if (cross > 0. && dir > 0) || (cross < 0. &&... | code_fim | hard | {
"lang": "rust",
"repo": "jrmuizel/raqote",
"path": "/src/path_builder.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn parse_hex_or_decimal(src: &str) -> std::result::Result<u64, std::num::ParseIntError> {
let src_trim = src.trim_start_matches("0x");
if src_trim.len() != src.len() {
u64::from_str_radix(src_trim, 16)
} else {
src_trim.parse::<u64>()
}
}
#[derive(Debug, Parser)]
#[clap(
... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/hhvm",
"path": "/hphp/hack/src/heap/dump_saved_state_depgraph.rs",
"mode": "spm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebook/hhvm path: /hphp/hack/src/heap/dump_saved_state_depgraph.rs
// Copyright (c) 2021, Facebook, Inc.
// All rights reserved.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use depgraph_reader::Dep;
use dep... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/hhvm",
"path": "/hphp/hack/src/heap/dump_saved_state_depgraph.rs",
"mode": "psm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Parser)]
#[clap(
name = "dump_saved_state_depgraph",
about = "
Common usage is to provide two file arguments to compare, 'test' and 'control'.
Example invocation:
dump_saved_state_depgraph --bitness 32 \\
--test path/to/test.bin --control path/to/control.bin
Exit code wi... | code_fim | hard | {
"lang": "rust",
"repo": "facebook/hhvm",
"path": "/hphp/hack/src/heap/dump_saved_state_depgraph.rs",
"mode": "spm",
"license": "PHP-3.01",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: morwoen/rbe path: /src/lib.rs
extern crate sdl2;
use sdl2::render::Renderer;
<|fim_suffix|>pub trait Drawable {
fn draw (&self, renderer: &mut Renderer);
}<|fim_middle|>// parsing and layout generation
pub mod dom;
pub mod html;
pub mod css;
pub mod style;
pub mod layout;
pub mod parser;
pu... | code_fim | hard | {
"lang": "rust",
"repo": "morwoen/rbe",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: morwoen/rbe path: /src/lib.rs
extern crate sdl2;
use sdl2::render::Renderer;
<|fim_suffix|>// network module
pub mod network;
pub trait Drawable {
fn draw (&self, renderer: &mut Renderer);
}<|fim_middle|>// parsing and layout generation
pub mod dom;
pub mod html;
pub mod css;
pub mod style... | code_fim | hard | {
"lang": "rust",
"repo": "morwoen/rbe",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait Drawable {
fn draw (&self, renderer: &mut Renderer);
}<|fim_prefix|>// repo: morwoen/rbe path: /src/lib.rs
extern crate sdl2;
use sdl2::render::Renderer;
<|fim_middle|>// parsing and layout generation
pub mod dom;
pub mod html;
pub mod css;
pub mod style;
pub mod layout;
pub mod parser;
pu... | code_fim | hard | {
"lang": "rust",
"repo": "morwoen/rbe",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: microcluster/devand path: /devand-ui/src/app/components/common/count_tag.rs
use yew::prelude::*;
use yewtil::{Pure, PureComponent};
<|fim_suffix|> if self.count > 0 {
html! { <span class="devand-count-tag">{ self.count }</span> }
} else {
html! {}
... | code_fim | hard | {
"lang": "rust",
"repo": "microcluster/devand",
"path": "/devand-ui/src/app/components/common/count_tag.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(PartialEq, Properties, Clone)]
pub struct PureCountTag {
pub count: usize,
}
impl PureComponent for PureCountTag {
fn render(&self) -> Html {
if self.count > 0 {
html! { <span class="devand-count-tag">{ self.count }</span> }
} else {
html! {}
... | code_fim | easy | {
"lang": "rust",
"repo": "microcluster/devand",
"path": "/devand-ui/src/app/components/common/count_tag.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.count > 0 {
html! { <span class="devand-count-tag">{ self.count }</span> }
} else {
html! {}
}
}
}<|fim_prefix|>// repo: microcluster/devand path: /devand-ui/src/app/components/common/count_tag.rs
use yew::prelude::*;
use yewtil::{Pure, PureComp... | code_fim | hard | {
"lang": "rust",
"repo": "microcluster/devand",
"path": "/devand-ui/src/app/components/common/count_tag.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mozilla-iam/dino-park-fence path: /src/graphql_api/root.rs
use crate::graphql_api::error::field_error;
use crate::graphql_api::input::InputProfile;
use crate::metrics::Metrics;
use crate::settings::DinoParkServices;
use cis_client::error::ProfileError;
use cis_client::getby::GetBy;
use cis_clien... | code_fim | hard | {
"lang": "rust",
"repo": "mozilla-iam/dino-park-fence",
"path": "/src/graphql_api/root.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub type Schema<T> = RootNode<
'static,
Query<T>,
Mutation<T>,
juniper::EmptySubscription<(ScopeAndUser, Arc<Metrics>)>,
>;
struct GetProfileParams {
id: String,
by: GetBy,
filter: Display,
}
fn get_profile_params(
username: Option<String>,
scope_and_user: &ScopeAndUs... | code_fim | hard | {
"lang": "rust",
"repo": "mozilla-iam/dino-park-fence",
"path": "/src/graphql_api/root.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if p.eat(Colon) {
types::typ(p);
p.finish_at(checkpoint, AnnotationP);
return true;
}
return false;
}<|fim_prefix|>// repo: C0d3GGz/Lambda3 path: /src/parser/patterns.rs
use super::*;
use crate::lexer::SyntaxKind::*;
pub fn parse_pattern(p: &mut Parser) {
let che... | code_fim | medium | {
"lang": "rust",
"repo": "C0d3GGz/Lambda3",
"path": "/src/parser/patterns.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: C0d3GGz/Lambda3 path: /src/parser/patterns.rs
use super::*;
use crate::lexer::SyntaxKind::*;
pub fn parse_pattern(p: &mut Parser) {
let checkpoint = p.checkpoint();
let current = p.current();
match current {
Ident => {
p.bump(Ident);
p.finish_at(chec... | code_fim | medium | {
"lang": "rust",
"repo": "C0d3GGz/Lambda3",
"path": "/src/parser/patterns.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Herbstein/BurgerBackend path: /src/crypto/authn.rs
use std::fs;
use anyhow::Result;
use bytes::BytesMut;
use chrono::{Duration, Local};
use crypto::{blake2b::Blake2b, digest::Digest};
use ed25519_dalek::{
ed25519::signature::Signature as _, Keypair, Signature, SignatureError, Signer,
};
use... | code_fim | hard | {
"lang": "rust",
"repo": "Herbstein/BurgerBackend",
"path": "/src/crypto/authn.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fs::create_dir_all(KEYS_FOLDER)?;
fs::write(keyfile, self.to_str())?;
Ok(self)
}
fn from_file(keyfile: &str) -> Result<Self> {
let content_str = fs::read_to_string(keyfile)?;
Self::from_str(&content_str)
}
fn from_file_or_new(keyfile: &str) -> Resu... | code_fim | hard | {
"lang": "rust",
"repo": "Herbstein/BurgerBackend",
"path": "/src/crypto/authn.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn to_file(&self, keyfile: &str) -> Result<&Self> {
fs::create_dir_all(KEYS_FOLDER)?;
fs::write(keyfile, self.to_str())?;
Ok(self)
}
fn from_file(keyfile: &str) -> Result<Self> {
let content_str = fs::read_to_string(keyfile)?;
Self::from_str(&content_st... | code_fim | hard | {
"lang": "rust",
"repo": "Herbstein/BurgerBackend",
"path": "/src/crypto/authn.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m9s/xmc1000 path: /xmc1000/src/ppb/icsr/mod.rs
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::ICSR {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn ... | code_fim | hard | {
"lang": "rust",
"repo": "m9s/xmc1000",
"path": "/xmc1000/src/ppb/icsr/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>//Write mode DataByte5
pub const WM_DB5_PLLREF: usize = 7;
pub const WM_DB5_DTC: usize = 6;
//Read mode DataByte1
pub const RM_DB1_RF: usize = 7;
pub const RM_DB1_BLF: usize = 6;
pub const RM_DB1_PLL: Range<usize> = 0..6;
//Read mode DataByte2
pub const RM_DB2_PLL: Range<usize> = 0..8;
//Read mode Data... | code_fim | hard | {
"lang": "rust",
"repo": "Nekspire/tea5767",
"path": "/src/regs.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>//Read mode DataByte1
pub const RM_DB1_RF: usize = 7;
pub const RM_DB1_BLF: usize = 6;
pub const RM_DB1_PLL: Range<usize> = 0..6;
//Read mode DataByte2
pub const RM_DB2_PLL: Range<usize> = 0..8;
//Read mode DataByte3
pub const RM_DB3_STEREO: usize = 7;
pub const WM_DB3_IF: Range<usize> = 0..6;
//Read m... | code_fim | hard | {
"lang": "rust",
"repo": "Nekspire/tea5767",
"path": "/src/regs.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nekspire/tea5767 path: /src/regs.rs
use embedded_hal::blocking::i2c::{Write, Read};
use core::ops::Range;
pub const DEVICE_ADDRESS: u8 = 0x60;
// Hal I2C write binding
pub fn write_data<I2C, E>(i2c: &mut I2C, data: [u8; 5]) -> Result<(), E>
where I2C: Write<Error = E>,
{
i2c.write(DEVICE_... | code_fim | hard | {
"lang": "rust",
"repo": "Nekspire/tea5767",
"path": "/src/regs.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>where
P: AsRef<std::path::Path>,
{
let path = path.as_ref();
let rgba_image = image::open(&std::path::Path::new(&path)).unwrap().to_rgba();
let image_dimensions = rgba_image.dimensions();
let raw_image = glium::texture::RawImage2d::from_raw_rgba_reversed(
&rgba_image.into_raw()... | code_fim | hard | {
"lang": "rust",
"repo": "scottschroeder/overwatch-3v3",
"path": "/manager-gui/src/image_util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scottschroeder/overwatch-3v3 path: /manager-gui/src/image_util.rs
pub type ImageMap = conrod_core::image::Map<glium::texture::Texture2d>;
pub type ImageId = conrod_core::image::Id;
use overwatch::Hero;
use std::collections::BTreeMap;
<|fim_suffix|> let portrait_dir = assets.join(OVERWATCH_P... | code_fim | hard | {
"lang": "rust",
"repo": "scottschroeder/overwatch-3v3",
"path": "/manager-gui/src/image_util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let portrait_dir = assets.join(OVERWATCH_PORTRAITS);
overwatch::Hero::iter()
.map(|h| {
let mut hero_portrait = portrait_dir.clone();
hero_portrait.push(h.blizzard_name());
hero_portrait.set_extension("png");
//let img = conrod_core::image::o... | code_fim | hard | {
"lang": "rust",
"repo": "scottschroeder/overwatch-3v3",
"path": "/manager-gui/src/image_util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let def_item = "item".to_string();
let def_index = "index".to_string();
let collection = x.attributes.get("collection").unwrap_or(&empty_string).to_string();
let item = x.attributes.get("item").unwrap_or(&def_item).to_string();
... | code_fim | hard | {
"lang": "rust",
"repo": "KaoImin/rbaits_sql",
"path": "/rbatis-sql-macro/src/parser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KaoImin/rbaits_sql path: /rbatis-sql-macro/src/parser.rs
include" => {
let refid = x.attributes.get("refid").expect("[rbatis] <include> element must have refid!").clone();
let data_url = Url::parse(format!("url://{}", refid).as_str()).expect("[rbatis] parse includ... | code_fim | hard | {
"lang": "rust",
"repo": "KaoImin/rbaits_sql",
"path": "/rbatis-sql-macro/src/parser.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> "where" => {
impl_trim("", " ", "and |or ", " and| or", x, &mut body, arg, methods, &format!("{}:{}", block_name, "where:trim"), format_char, ignore);
}
"choose" => {
let mut inner_body = quote! {};
for x in &x.childs {
... | code_fim | hard | {
"lang": "rust",
"repo": "KaoImin/rbaits_sql",
"path": "/rbatis-sql-macro/src/parser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let foo = Four {
a: Two { a: 18, b: 23 },
b: Two { a: 19, b: 24 },
};
assert_eq!(foo.into_repr().acc(), 84);
}<|fim_prefix|>// repo: erikdesjardins/generics path: /tests/struct_nested.rs
use generics::{Generic, Prod, Unit};
trait Accumulate {
fn acc(self) -> u64;
}
impl... | code_fim | medium | {
"lang": "rust",
"repo": "erikdesjardins/generics",
"path": "/tests/struct_nested.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erikdesjardins/generics path: /tests/struct_nested.rs
use generics::{Generic, Prod, Unit};
trait Accumulate {
fn acc(self) -> u64;
}
impl Accumulate for u64 {
fn acc(self) -> u64 {
self
}
}
<|fim_suffix|> let Prod(a, b) = self;
a.acc() + b.acc()
}
}
#[d... | code_fim | medium | {
"lang": "rust",
"repo": "erikdesjardins/generics",
"path": "/tests/struct_nested.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chorddown/chordr path: /webchordr/app/src/components/song_search/mod.rs
use std::rc::Rc;
use gloo_timers::callback::Timeout;
use log::{debug, info};
use web_sys::HtmlInputElement;
use yew::prelude::*;
use yew::Component;
use libchordr::models::catalog::*;
use libchordr::models::list::ListEntry... | code_fim | hard | {
"lang": "rust",
"repo": "chorddown/chordr",
"path": "/webchordr/app/src/components/song_search/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> true
}
}
}
fn changed(&mut self, ctx: &Context<Self>, _old_props: &Self::Properties) -> bool {
let catalog_changed = ctx.props().catalog.revision() != self.catalog_revision;
if catalog_changed {
self.search_index = None;
... | code_fim | hard | {
"lang": "rust",
"repo": "chorddown/chordr",
"path": "/webchordr/app/src/components/song_search/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> props.catalog.iter().collect::<Vec<&Song>>().sort_by_title()
}
fn needs_to_build_search_index(&self) -> bool {
!self.search.is_empty() && !self.search.trim().is_empty() && self.search_index.is_none()
}
fn get_back_link(&self, ctx: &Context<Self>) -> Html {
(if ctx... | code_fim | hard | {
"lang": "rust",
"repo": "chorddown/chordr",
"path": "/webchordr/app/src/components/song_search/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wulu90/leetcode path: /src/balanced_binary_tree.rs
use super::leetcode::binary_tree::TreeNode;
use std::cell::RefCell;
use std::collections::VecDeque;
use std::rc::Rc;
pub struct Solution;
impl Solution {
pub fn is_balanced(root: Option<Rc<RefCell<TreeNode>>>) -> bool {
let mut que... | code_fim | hard | {
"lang": "rust",
"repo": "wulu90/leetcode",
"path": "/src/balanced_binary_tree.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod test {
use super::Solution;
use crate::binarytree;
#[test]
fn is_balanced() {
assert_eq!(true, Solution::is_balanced(binarytree![]));
assert_eq!(true, Solution::is_balanced(binarytree![1]));
assert_eq!(true, Solution::is_balanced(binarytree![1, 2])... | code_fim | hard | {
"lang": "rust",
"repo": "wulu90/leetcode",
"path": "/src/balanced_binary_tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(true, Solution::is_balanced(binarytree![]));
assert_eq!(true, Solution::is_balanced(binarytree![1]));
assert_eq!(true, Solution::is_balanced(binarytree![1, 2]));
assert_eq!(
true,
Solution::is_balanced(binarytree![3, 9, 20, null, null, 15,... | code_fim | hard | {
"lang": "rust",
"repo": "wulu90/leetcode",
"path": "/src/balanced_binary_tree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> socket.wait_until(|| stream.is_readable());
// Read the data out of the stream buffer
let mut buf = [0; 128];
assert_eq!(18, stream.read(&mut buf).unwrap());
assert_eq!(&buf[..18], b"this is my message");
th.join().unwrap();
}
#[test]
fn dropping_listener() {
const CONNECTIO... | code_fim | hard | {
"lang": "rust",
"repo": "carllerche/utp",
"path": "/src/test/test_listener.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: carllerche/utp path: /src/test/test_listener.rs
use super::prelude::*;
#[test]
fn accept_stream() {
const CONNECTION_ID: u16 = 25103;
let _ = ::env_logger::init();
::util::reset_rand();
let (socket, listener) = Harness::new();
let mock = Mock::new();
let server = mock.... | code_fim | hard | {
"lang": "rust",
"repo": "carllerche/utp",
"path": "/src/test/test_listener.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> -> a * b, ..
Div, // b, a, .. -> a / b, ..
Mod, // b, a, .. -> a % b, ..
In, // b, a, .. -> a in b, ..
Lt, // b, a, .. -> a < b, ..
Lte, // b, a, .. -> a <= b, ..
Gt, // b, a, .. -> a > b, ..
Gte, // b, a, .. -> a >= b, ..
Eq, // b, a, .. -> a = b, ..
Neq, // b, a, .. ... | code_fim | hard | {
"lang": "rust",
"repo": "reklawnos/housecat",
"path": "/src/evaluator/ops.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reklawnos/housecat path: /src/evaluator/ops.rs
use super::value::Value;
use super::environment::ValueHolder;
use std::cell::RefCell;
use std::rc::Rc;
#[derive(Debug, Clone)]
pub enum Op {
//Stack manipulation
Push(Box<Value>), // .. -> a, ..
PushClip(ClipParts), // .. -> clip, ..
... | code_fim | hard | {
"lang": "rust",
"repo": "reklawnos/housecat",
"path": "/src/evaluator/ops.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for uint::range(0, 16) |i| {
/* Should be in[i] = {r: 0.0f64, i: 0.0f64} ... */
c_vec::set(in, i, Zero::zero());
c_vec::set(out, i, Zero::zero());
}
c_vec::set(in, 2, Cmplx::new(1.0f64, 0.0f64));
p.execute();
assert!(approx_c64(c_vec::get(out, 0u), Cmplx::new... | code_fim | hard | {
"lang": "rust",
"repo": "jwise/rustfftw",
"path": "/fftw_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jwise/rustfftw path: /fftw_test.rs
extern mod std;
extern mod fftw;
use core::num::Zero;
use std::complex::{Cmplx, Complex64};
use std::c_vec;
static epsilon : f64 = 0.01f64;
fn approx(a: f64, b: f64) -> bool {
if ((a + epsilon) < b) { false }
else if ((a - epsilon) > b) { false }
... | code_fim | medium | {
"lang": "rust",
"repo": "jwise/rustfftw",
"path": "/fftw_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn basic() {
let in = fftw::malloc_cpx64(16);
let out = fftw::malloc_cpx64(16);
let p = fftw::Plan::dft_1d(16, in, out, fftw::FORWARD, fftw::MEASURE);
for uint::range(0, 16) |i| {
/* Should be in[i] = {r: 0.0f64, i: 0.0f64} ... */
c_vec::set(in, i, Zero::zero());... | code_fim | medium | {
"lang": "rust",
"repo": "jwise/rustfftw",
"path": "/fftw_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>c = "Getter for the `prefix` field of this object."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CSSCounterStyleRule/prefix)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `CssCounterStyleRule`*"]
pu... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/crates/web-sys/src/features/gen_CssCounterStyleRule.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustwasm/wasm-bindgen path: /crates/web-sys/src/features/gen_CssCounterStyleRule.rs
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = CssRule , extends = :: js_sys :: Object , js_name = CSSCoun... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/crates/web-sys/src/features/gen_CssCounterStyleRule.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>tring,
pub duration_secs: Option<i32>,
pub start_time: Option<NaiveDateTime>,
pub end_time: Option<NaiveDateTime>,
}<|fim_prefix|>// repo: alanhdu/rust-dashboard path: /src/domain/builds.rs
use chrono::NaiveDateTime;
use super::schema::*;
#[derive(AsChangeset, Clone, Debug, Deserialize, Eq, ... | code_fim | hard | {
"lang": "rust",
"repo": "alanhdu/rust-dashboard",
"path": "/src/domain/builds.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alanhdu/rust-dashboard path: /src/domain/builds.rs
use chrono::NaiveDateTime;
use super::schema::*;
#[derive(AsChangeset, Clone, Debug, Deserialize, Eq, Insertable,
Ord<|fim_suffix|>id: String,
pub env: String,
pub builder_name: String,
pub os: String,
pub successful: b... | code_fim | medium | {
"lang": "rust",
"repo": "alanhdu/rust-dashboard",
"path": "/src/domain/builds.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_mode_rx(&self) {
// BOTH: set radio to RX state
// AND: set radio to return to RX state when done with other states
self.set_rf_mode(RfState::SRX);
}
pub fn set_mode_idle(&self) {
// BOTH: set radio to IDLE state
// ... | code_fim | hard | {
"lang": "rust",
"repo": "thecubic/whiskers",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct RadioConfig {
}
impl RadioConfig {
fn from_bytes(v: Vec<u8>) -> Result<RadioConfig, libusb::Error> {
// deserialize here
Ok(RadioConfig{})
}
fn to_bytes(&self) -> Result<Vec<u8>, libusb::Error> {
Ok(vec![0])
}
}
// TODO: this should be a static ve... | code_fim | hard | {
"lang": "rust",
"repo": "thecubic/whiskers",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thecubic/whiskers path: /src/lib.rs
}
}
}
pub enum Addresses {
RfState = 0xDFE1,
}
#[derive(Copy, Clone, Hash, Eq, PartialEq)]
pub enum AppMailbox {
AppGeneric = 0x01,
AppDebug = 0xfe,
AppSystem = 0xff,
UNKNOWN = 0x00,
}
impl From<u8> for AppMailbox {
fn from(value: ... | code_fim | hard | {
"lang": "rust",
"repo": "thecubic/whiskers",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let handle = FakeObjectHandle::new(object.clone());
let mut buf = handle.allocate_buffer(object.get_size() as usize);
assert_eq!(buf.len(), TEST_BLOCK_SIZE);
handle.read(0, buf.as_mut()).await.expect("read failed");
let value: u64 = deserialize_from(&buf.as_slice()[... | code_fim | hard | {
"lang": "rust",
"repo": "dahliaOS/fuchsia-pi4",
"path": "/src/storage/fxfs/src/object_store/journal/writer.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dahliaOS/fuchsia-pi4 path: /src/storage/fxfs/src/object_store/journal/writer.rs
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::{
object_handle::ObjectHan... | code_fim | hard | {
"lang": "rust",
"repo": "dahliaOS/fuchsia-pi4",
"path": "/src/storage/fxfs/src/object_store/journal/writer.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> "NUD expected right parenthesis - '{:?}'",
t
)));
}
}
} else {
return Err(crate::error::parse_... | code_fim | hard | {
"lang": "rust",
"repo": "raystyle/tau-engine",
"path": "/src/parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raystyle/tau-engine path: /src/parser.rs
t
)));
}
}
} else {
return Err(crate::error::parse_invalid_token(
... | code_fim | hard | {
"lang": "rust",
"repo": "raystyle/tau-engine",
"path": "/src/parser.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> group.push(Expression::Search(Search::Exact(s), f.to_owned()));
} else if i.ignore_case {
icontext.push(MatchType::Exact(s.clone()));
ineedles.push(s);
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "raystyle/tau-engine",
"path": "/src/parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ocstl/project_euler path: /src/monopoly/mod.rs
use rand::{thread_rng, Rng};
const CHANCE_SIZE: u8 = 16;
const COMMUNITY_CHEST_SIZE: u8 = 16;
const DICE_SIZE: usize = 4;
const DOUBLE_ROLLS_JAIL: usize = 3;
fn roll() -> usize {
let mut rng = thread_rng();
rng.gen_range(0, DICE_SIZE) + 1
... | code_fim | hard | {
"lang": "rust",
"repo": "ocstl/project_euler",
"path": "/src/monopoly/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Since Chance can move us back unto a CommunityChest, we deal with it first. Sorry
// about the magic number.
if square == Square::Chance {
match Chance::draw() {
Chance::Go => self.go_to_go(),
Chance::Jail => self.go_to_jail(),
... | code_fim | hard | {
"lang": "rust",
"repo": "ocstl/project_euler",
"path": "/src/monopoly/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pnnl/lamellar-runtime path: /tests/array/bitwise_ops/and_test.rs
use lamellar::array::prelude::*;
macro_rules! initialize_array {
(UnsafeArray,$array:ident,$init_val:ident) => {
unsafe {
$array.dist_iter_mut().for_each(move |x| *x = $init_val);
}
$array.w... | code_fim | hard | {
"lang": "rust",
"repo": "pnnl/lamellar-runtime",
"path": "/tests/array/bitwise_ops/and_test.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ultracold273/leetcode-rs path: /src/contest_187/pr3.rs
use std::collections::BTreeMap;
fn longest_subarray(nums: Vec<i32>, limit: i32) -> i32 {
let mut longest = 0;
let mut map = BTreeMap::new();
let mut st = 0;
for ed in 0..nums.len(<|fim_suffix|>x = map.iter().rev().next().un... | code_fim | medium | {
"lang": "rust",
"repo": "ultracold273/leetcode-rs",
"path": "/src/contest_187/pr3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>= 0 {
map.remove(&nums[st]);
}
// map.remove(&nums[st]);
st += 1;
}
longest = longest.max(ed - st + 1);
}
longest as i32
}<|fim_prefix|>// repo: ultracold273/leetcode-rs path: /src/contest_187/pr3.rs
use std::collections::BTreeM... | code_fim | hard | {
"lang": "rust",
"repo": "ultracold273/leetcode-rs",
"path": "/src/contest_187/pr3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pchickey/posish path: /src/io/mod.rs
//! I/O operations.
mod fd;
mod poll;
#[cfg(not(target_os = "wasi"))]
mod socketpair;
#[cfg(not(target_os = "was<|fim_suffix|>use fd::is_read_write;
pub use fd::isatty;
#[cfg(not(any(target_os = "wasi", target_os = "fuchsia")))]
pub use fd::ttyname;
pub use... | code_fim | medium | {
"lang": "rust",
"repo": "pchickey/posish",
"path": "/src/io/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>use fd::is_read_write;
pub use fd::isatty;
#[cfg(not(any(target_os = "wasi", target_os = "fuchsia")))]
pub use fd::ttyname;
pub use poll::{PollFd, PollFdVec};
#[cfg(not(target_os = "wasi"))]
pub use socketpair::socketpair_stream;<|fim_prefix|>// repo: pchickey/posish path: /src/io/mod.rs
//! I/O operatio... | code_fim | medium | {
"lang": "rust",
"repo": "pchickey/posish",
"path": "/src/io/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: infinyon/flv-kf-protocol path: /kf-protocol-message/src/kf_code_gen/api_versions.rs
/// WARNING: CODE GENERATED FILE
/// * This file is generated by kfspec2code.
/// * Any changes applied to this file will be lost when a new spec is generated.
use serde::{Deserialize, Serialize};
use kf_protoco... | code_fim | hard | {
"lang": "rust",
"repo": "infinyon/flv-kf-protocol",
"path": "/kf-protocol-message/src/kf_code_gen/api_versions.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Request for KfApiVersionsRequest {
const API_KEY: u16 = 18;
const MIN_API_VERSION: i16 = 0;
const MAX_API_VERSION: i16 = 2;
const DEFAULT_API_VERSION: i16 = 2;
type Response = KfApiVersionsResponse;
}<|fim_prefix|>// repo: infinyon/flv-kf-protocol path: /kf-protocol-message/src... | code_fim | medium | {
"lang": "rust",
"repo": "infinyon/flv-kf-protocol",
"path": "/kf-protocol-message/src/kf_code_gen/api_versions.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: whuthj/conrod path: /src/widget/xy_pad.rs
use {
CharacterCache,
Color,
Colorable,
Frameable,
FramedRectangle,
FontSize,
IndexSlot,
Labelable,
Line,
Mouse,
Positionable,
Scalar,
Sizeable,
Text,
Widget,
};
use num::Float;
use widget;
use... | code_fim | hard | {
"lang": "rust",
"repo": "whuthj/conrod",
"path": "/src/widget/xy_pad.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let widget::UpdateArgs { idx, state, rect, style, mut ui, .. } = args;
let XYPad {
enabled,
x, min_x, max_x,
y, min_y, max_y,
maybe_label,
maybe_react,
..
} = self;
let maybe_mouse = ui.input().maybe_m... | code_fim | hard | {
"lang": "rust",
"repo": "whuthj/conrod",
"path": "/src/widget/xy_pad.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let value_or_bounds_have_changed = {
let v = state.view();
v.x != x || v.y != y
|| v.min_x != min_x || v.max_x != max_x
|| v.min_y != min_y || v.max_y != max_y
};
if value_or_bounds_have_changed {
state.update(|st... | code_fim | hard | {
"lang": "rust",
"repo": "whuthj/conrod",
"path": "/src/widget/xy_pad.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn save(&self, output: &mut File) -> io::Result<()> {
serde::encode_vec(output, &self.chr_rom)?;
serde::encode_vec(output, &self.prg_rom)?;
serde::encode_u8(output, self.prg_bank)?;
serde::encode_u8(output, self.chr_bank0)?;
serde::encode_u8(output, self.chr_ban... | code_fim | hard | {
"lang": "rust",
"repo": "ltriant/nes",
"path": "/src/mapper/mapper34.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ltriant/nes path: /src/mapper/mapper34.rs
use std::collections::HashSet;
use std::io;
use std::fs::File;
use crate::mapper::Mapper;
use crate::mapper::MirrorMode;
use crate::serde;
const PRG_BANK_SIZE: usize = 32768;
const CHR_BANK_SIZE: usize = 4096;
#[derive(Clone, Copy, Debug)]
enum Board ... | code_fim | hard | {
"lang": "rust",
"repo": "ltriant/nes",
"path": "/src/mapper/mapper34.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // These registers reside "on top" of PRG RAM: each write to the register goes
// both to the register and to the RAM location at the same address. Thus,
// reading the register's address returns the last value written to the RAM,
... | code_fim | hard | {
"lang": "rust",
"repo": "ltriant/nes",
"path": "/src/mapper/mapper34.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let try_read_vars = record_struct.fields.iter().map(|ref x| {
let name = x.ident.as_ref().unwrap();
let ty = &x.ty;
let missing = match default_attr(x) {
Some(ts) => ts,
None => quote! { return Err(byte::Error::Incomplete) },
};
match (ar... | code_fim | hard | {
"lang": "rust",
"repo": "cmars/stdf",
"path": "/stdf-record-derive/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cmars/stdf path: /stdf-record-derive/src/lib.rs
extern crate proc_macro;
extern crate proc_macro2;
#[macro_use]
extern crate syn;
#[macro_use]
extern crate quote;
use proc_macro::TokenStream;
use syn::{parse_macro_input, DeriveInput};
fn attr_name(a: &syn::Path) -> String {
a.segments
... | code_fim | hard | {
"lang": "rust",
"repo": "cmars/stdf",
"path": "/stdf-record-derive/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Roba1993/Business-Model-Executor path: /examples/bme.rs
fn main() {
// define the rule
let logic = bme::Logic::default();
println!(
"{}",
serde_json::to_string_pretty(&logic.get_json()).unwrap()
);
println!("");
// parse the code from json to the objects... | code_fim | hard | {
"lang": "rust",
"repo": "Roba1993/Business-Model-Executor",
"path": "/examples/bme.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pe":"i64","startBlock":5,"endBlock":6,"startNode":3,"endNode":2}]},{"id":4,"nodeType":"input","connectionType":"i64","value":"1","connections":[]}]},{"blockId":7,"blockTypeId":2,"position":{"x":1036,"y":139},"nodes":[{"id":0,"nodeType":"input","connectionType":"Execution","value":null,"connections":[{"typ... | code_fim | hard | {
"lang": "rust",
"repo": "Roba1993/Business-Model-Executor",
"path": "/examples/bme.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>de":1,"endNode":0}]},{"id":1,"nodeType":"output","connectionType":"Execution","value":null,"connections":[{"type":"Execution","startBlock":3,"endBlock":7,"startNode":1,"endNode":0}]},{"id":2,"nodeType":"input","connectionType":"String","value":null,"connections":[{"type":"String","startBlock":4,"endBlock"... | code_fim | hard | {
"lang": "rust",
"repo": "Roba1993/Business-Model-Executor",
"path": "/examples/bme.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ivan3101/simple-rustacean-server path: /src/main.rs
mod server;
mod http;
<|fim_suffix|> let server = Server::new(String::from("127.0.0.1:8000"));
server.run();
}<|fim_middle|>use server::Server;
use http::Request;
fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "ivan3101/simple-rustacean-server",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let server = Server::new(String::from("127.0.0.1:8000"));
server.run();
}<|fim_prefix|>// repo: ivan3101/simple-rustacean-server path: /src/main.rs
mod server;
mod http;
use server::Server;
use http::Request;
<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "ivan3101/simple-rustacean-server",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ivan3101/simple-rustacean-server path: /src/main.rs
mod server;
mod http;
<|fim_suffix|>fn main() {
let server = Server::new(String::from("127.0.0.1:8000"));
server.run();
}<|fim_middle|>use server::Server;
use http::Request;
| code_fim | easy | {
"lang": "rust",
"repo": "ivan3101/simple-rustacean-server",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct WacthSettings {
paths: Vec<PathBuf>,
mode: watcher::Mode,
delay: watcher::Delay
}
impl Service for Watcher {
type Request = WacthSettings;
type Response = watcher::EventStream;
type Error = ();
type Future = BoxFuture<Self::Response, Self::Error>;
fn call (&self, request:Self::... | code_fim | medium | {
"lang": "rust",
"repo": "Gozala/fs-watch-service",
"path": "/src/service.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Gozala/fs-watch-service path: /src/service.rs
extern crate notify;
extern crate futures;
extern crate tokio_service;
use watcher;
use futures::{future, Future, BoxFuture};
use std::path::{PathBuf};
use self::tokio_service::Service;
pub struct Watcher;
<|fim_suffix|> let response = watcher... | code_fim | hard | {
"lang": "rust",
"repo": "Gozala/fs-watch-service",
"path": "/src/service.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let response = watcher::watch(request.paths, request.mode, request.delay);
future::ok(response).boxed()
}
}<|fim_prefix|>// repo: Gozala/fs-watch-service path: /src/service.rs
extern crate notify;
extern crate futures;
extern crate tokio_service;
use watcher;
use futures::{future, Future, Bo... | code_fim | hard | {
"lang": "rust",
"repo": "Gozala/fs-watch-service",
"path": "/src/service.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeschkies/influxdb_iox path: /server/src/buffer.rs
or
// something recent.
for w in self.open_segment.writes.iter().rev() {
let (writer, sequence) = w.writer_and_sequence();
if writer == since.id {
if sequence == since.sequence {
... | code_fim | hard | {
"lang": "rust",
"repo": "jeschkies/influxdb_iox",
"path": "/server/src/buffer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let write = lp_to_replicated_write(1, 2, "cpu val=1 10");
let segment = buf.append(write).await.unwrap();
let segment = segment.unwrap();
assert_eq!(2, segment.id);
assert_eq!(2, buf.closed_segments.len());
assert_eq!(1, buf.closed_segments[0].id);
... | code_fim | hard | {
"lang": "rust",
"repo": "jeschkies/influxdb_iox",
"path": "/server/src/buffer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeschkies/influxdb_iox path: /server/src/buffer.rs
w(dead_code)]
pub fn writes_since(&self, since: WriterSequence) -> Vec<Arc<ReplicatedWrite>> {
let mut writes = Vec::new();
// start with the newest writes and go back. Hopefully they're asking for
// something recen... | code_fim | hard | {
"lang": "rust",
"repo": "jeschkies/influxdb_iox",
"path": "/server/src/buffer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pawroman/torchbear path: /src/bindings/crypto/hash.rs
use rlua::{Error as LuaError, Context};
use blake2::*;
use sodiumoxide::crypto::hash;
use base64;
<|fim_suffix|>/// Returns base64 encoded BLAKE2B of `msg`
pub fn blake2_hash(_lua: Context, msg: String) -> Result<String, LuaError> {
let ... | code_fim | medium | {
"lang": "rust",
"repo": "pawroman/torchbear",
"path": "/src/bindings/crypto/hash.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Returns base64 encoded BLAKE2B of `msg`
pub fn blake2_hash(_lua: Context, msg: String) -> Result<String, LuaError> {
let mut hasher = Blake2b::new();
hasher.input(msg);
let digest = hasher.result();
Ok(base64::encode(&digest))
}<|fim_prefix|>// repo: pawroman/torchbear path: /src/bind... | code_fim | medium | {
"lang": "rust",
"repo": "pawroman/torchbear",
"path": "/src/bindings/crypto/hash.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cargill/splinter path: /services/scabbard/libscabbard/src/service/v3/lifecycle.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 ... | code_fim | hard | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/services/scabbard/libscabbard/src/service/v3/lifecycle.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<K> ScabbardLifecycle<K> {
pub fn new(store_factory: Arc<dyn ScabbardStoreFactory<K>>) -> Self {
Self { store_factory }
}
}
impl<K> Lifecycle<K> for ScabbardLifecycle<K>
where
K: 'static,
{
type Arguments = ScabbardArguments;
fn command_to_prepare(
&self,
... | code_fim | hard | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/services/scabbard/libscabbard/src/service/v3/lifecycle.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SimY4/advent-of-code-rust path: /src/y2015/day3.rs
use std::collections::HashSet;
fn navigate((x, y): (i32, i32), direction: char) -> (i32, i32) {
match direction {
'<' => (x - 1, y),
'>' => (x + 1, y),
'^' => (x, y + 1),
'v' => (x, y - 1),
_ => unrea... | code_fim | hard | {
"lang": "rust",
"repo": "SimY4/advent-of-code-rust",
"path": "/src/y2015/day3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>^>v^v>^<^v^<<vvv^^<>^v<<^>^<><>^^<>>^^<^v^<^<v<><<^><v<>v^^>v^v^^^<^v<<^v>^>>^^^^^><<<vv^>>v^><v^^vv><>v^^<^v<^<v^^><<v>v^^^><^^^><<<<<>^<<^<>>v<<v^v^^v<<>^<vv>>><^^^<>>>>vvv>v<>>>v^v^v<^<<^>^<<>v>>^>^^><^><<^v^^<^<>v^v>vv<>>>>>>v<<><v^<v<>>^^>v<<<>^<<v><^><<^v>vv>>>><><>v^<^v><v^<<<<^v><^>v>>^^^v<^>>^>>v... | code_fim | hard | {
"lang": "rust",
"repo": "SimY4/advent-of-code-rust",
"path": "/src/y2015/day3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FloydATC/rlox path: /src/lox/common/value/obj/closure.rs
use std::cell::Ref;
use crate::lox::vm::Upvalue; // Runtime representation
use super::{Function, Value};
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct Closure {
// Functions are first class objects so they're stored in ... | code_fim | hard | {
"lang": "rust",
"repo": "FloydATC/rlox",
"path": "/src/lox/common/value/obj/closure.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn function_ref(&self) -> Ref<'_, Function> {
return self.function_value.as_function();
}
pub fn add_upvalue(&mut self, upvalue: Upvalue<Value>) {
println!("Closure.add_upvalue() adding value={} as index={} of closure \"{}\"", upvalue, self.upvalues.len(), self.function_r... | code_fim | hard | {
"lang": "rust",
"repo": "FloydATC/rlox",
"path": "/src/lox/common/value/obj/closure.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn add_upvalue(&mut self, upvalue: Upvalue<Value>) {
println!("Closure.add_upvalue() adding value={} as index={} of closure \"{}\"", upvalue, self.upvalues.len(), self.function_ref().name());
self.upvalues.push(upvalue);
}
pub fn upvalue_ref_by_id(&self, id: usize) -> ... | code_fim | medium | {
"lang": "rust",
"repo": "FloydATC/rlox",
"path": "/src/lox/common/value/obj/closure.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /**
* Visit a parse tree produced by the {@code multiply}
* labeled alternative in {@link VisitorCalcParser#expr}.
* @param ctx the parse tree
*/
fn visit_multiply(&mut self, ctx: &MultiplyContext<'input>) -> Self::Return {
self.visit_children(ctx)
}
}
impl<'input,... | code_fim | hard | {
"lang": "rust",
"repo": "rrevenantt/antlr4rust",
"path": "/tests/gen/visitorcalcvisitor.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rrevenantt/antlr4rust path: /tests/gen/visitorcalcvisitor.rs
#![allow(nonstandard_style)]
// Generated from VisitorCalc.g4 by ANTLR 4.8
use super::visitorcalcparser::*;
use antlr_rust::tree::{ParseTreeVisitor, ParseTreeVisitorCompat};
/**
* This interface defines a complete generic visitor for... | code_fim | hard | {
"lang": "rust",
"repo": "rrevenantt/antlr4rust",
"path": "/tests/gen/visitorcalcvisitor.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.