text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>
let preorder = vec![3,9,20,15,7];
let inorder = vec![9,3,15,20,7];
let ret = vec![Some(3), Some(9), Some(20), None, None, Some(15), Some(7)];
assert_eq!(TreeNode::make_list_from_tree(Solution::build_tree(preorder, inorder)), ret);
}<|fim_prefix|>// repo: pipi32167/LeetCode path: /rust/src/p... | code_fim | hard | {
"lang": "rust",
"repo": "pipi32167/LeetCode",
"path": "/rust/src/problem_offer_07.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let file = File::open("data/input12.txt").unwrap();
let reader = BufReader::new(file);
let mut reactions = vec![];
for line in reader.lines() {
let s = line.unwrap();
let (_, r) = parse_vector(&s).unwrap();
reactions.push(r);
}
reactions
}
#[derive(Debug, ... | code_fim | hard | {
"lang": "rust",
"repo": "mattiast/aoc2019",
"path": "/src/day12.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mattiast/aoc2019 path: /src/day12.rs
use itertools::izip;
use nom::{
bytes::complete::{tag, take_while1},
combinator::map_res,
IResult,
};
use num::integer::lcm;
use std::cmp::Ordering;
use std::fs::File;
use std::io::{prelude::BufRead, BufReader};
fn parse_number(input: &str) -> IR... | code_fim | hard | {
"lang": "rust",
"repo": "mattiast/aoc2019",
"path": "/src/day12.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn one_round(moons: &mut [Position]) {
Position::apply_gravity(moons);
for moon in moons {
moon.move_pos();
}
}
fn get_round_length(moons: &mut [Position]) -> usize {
let original: Vec<_> = moons.to_vec();
one_round(moons);
let mut n = 1;
loop {
let mats = moon... | code_fim | hard | {
"lang": "rust",
"repo": "mattiast/aoc2019",
"path": "/src/day12.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonlamb-gh/heli-x-scene3d-tool-rs path: /src/terrain_mode.rs
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum TerrainMode {
/// Colored points and lines
Wireframe,
/// Colored points
Points,
/// Solid, colored material
Solid,
/// Solid, color provided by the heig... | code_fim | hard | {
"lang": "rust",
"repo": "jonlamb-gh/heli-x-scene3d-tool-rs",
"path": "/src/terrain_mode.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ints => TerrainMode::Solid,
TerrainMode::Solid => TerrainMode::Textured,
TerrainMode::Textured => TerrainMode::Alphamap,
TerrainMode::Alphamap => TerrainMode::Wireframe,
}
}
}<|fim_prefix|>// repo: jonlamb-gh/heli-x-scene3d-tool-rs path: /src/terrain_mode.r... | code_fim | hard | {
"lang": "rust",
"repo": "jonlamb-gh/heli-x-scene3d-tool-rs",
"path": "/src/terrain_mode.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: neurogoo/rust-ray-tracer path: /src/hitable/bvhnode.rs
use rand::{thread_rng, Rng};
use std::cmp::Ordering;
use ray::*;
use hitable::{HitRecord, Hitable};
use utils::{surrounding_box, Aabb};
#[derive(Clone, Debug)]
pub struct BvhNode {
left: Box<Hitable>,
right: Box<Hitable>,
bbox:... | code_fim | hard | {
"lang": "rust",
"repo": "neurogoo/rust-ray-tracer",
"path": "/src/hitable/bvhnode.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn box_z_compare(a: &Hitable, b: &Hitable) -> Ordering {
match (a.bounding_box(0.0, 0.0), b.bounding_box(0.0, 0.0)) {
(None, _) => println!("No bounding box in bcvh_node construstor"),
(_, None) => println!("No bounding box in bcvh_node construstor"),
(Some(box_left), Some(box_... | code_fim | hard | {
"lang": "rust",
"repo": "neurogoo/rust-ray-tracer",
"path": "/src/hitable/bvhnode.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (a, b) = self.smallest_sides();
a + a + b + b + self.volume()
}
fn area(&self) -> u32 {
// Present(l, w, h) = self;
2 * self.l * self.w + 2 * self.w * self.h + 2 * self.h * self.l
}
fn smallest_sides(&self) -> (u32, u32) {
if self.l > std::cmp:... | code_fim | medium | {
"lang": "rust",
"repo": "thvdburgt/advent-of-code-2015",
"path": "/day-2-i-was-told-there-would-be-no-math/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (a, b) = self.smallest_sides();
a * b
}
fn volume(&self) -> u32 {
self.l * self.w * self.h
}
}
impl FromStr for Present {
type Err = ParsePresentError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let dims: Vec<_> = s.split_terminator('x').co... | code_fim | hard | {
"lang": "rust",
"repo": "thvdburgt/advent-of-code-2015",
"path": "/day-2-i-was-told-there-would-be-no-math/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thvdburgt/advent-of-code-2015 path: /day-2-i-was-told-there-would-be-no-math/src/lib.rs
use std::str::FromStr;
pub fn solve_puzzle_part_1(input: &str) -> u32 {
input
.lines()
.map(|l: &str| {
let present: Present = l.parse().unwrap();
present.wrapping... | code_fim | medium | {
"lang": "rust",
"repo": "thvdburgt/advent-of-code-2015",
"path": "/day-2-i-was-told-there-would-be-no-math/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mkmojo/porus-1 path: /src/list/sorting.rs
use super::ViewMut;
use super::{get, iter, slice_mut, swap, List, ListMut};
use crate::collection::{self, Collection};
use core::cmp::Ordering::{Greater, Less};
#[allow(clippy::nonminimal_bool)]
pub fn is_stable_sort<
E,
L: List<Elem = E> + Coll... | code_fim | hard | {
"lang": "rust",
"repo": "mkmojo/porus-1",
"path": "/src/list/sorting.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn shell_sort<
E,
L: ListMut<Elem = E> + Collection,
F: Fn(&E, &E) -> bool,
G: List<Elem = usize> + Collection,
>(
list: &mut L,
lt: F,
gaps: &G,
) -> usize {
let mut count = 0;
for g in iter(gaps) {
// for i in 0..g {
// count += insertion_sort(... | code_fim | hard | {
"lang": "rust",
"repo": "mkmojo/porus-1",
"path": "/src/list/sorting.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, K: Eq + Hash, S: BuildHasher> Deref for Ref<'a, K, S> {
type Target = K;
fn deref(&self) -> &K {
self.key()
}
}<|fim_prefix|>// repo: xacrimon/dashmap path: /src/setref/one.rs
use crate::mapref;
use core::hash::{BuildHasher, Hash};
use core::ops::Deref;
use std::collections:... | code_fim | medium | {
"lang": "rust",
"repo": "xacrimon/dashmap",
"path": "/src/setref/one.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xacrimon/dashmap path: /src/setref/one.rs
use crate::mapref;
use core::hash::{BuildHasher, Hash};
use core::ops::Deref;
use std::collections::hash_map::RandomState;
pub struct Ref<'a, K, S = RandomState> {
inner: mapref::one::Ref<'a, K, (), S>,
}
<|fim_suffix|>impl<'a, K: Eq + Hash, S: Buil... | code_fim | hard | {
"lang": "rust",
"repo": "xacrimon/dashmap",
"path": "/src/setref/one.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vidarr/rustydns path: /tests/dnslabel_tests.rs
// Copyright (c) 2018, Michael J. Beer
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source ... | code_fim | hard | {
"lang": "rust",
"repo": "vidarr/rustydns",
"path": "/tests/dnslabel_tests.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
assert!(hash_label("") == hash_label(""));
assert!(hash_label("1") == hash_label("1"));
assert!(hash_label("a") == hash_label("a"));
assert!(hash_label("aa") == hash_label("aa"));
assert!(hash_label("A") == hash_label("a"));
assert!(hash_label("dhgfe") == hash_label("dhgfe"));
... | code_fim | hard | {
"lang": "rust",
"repo": "vidarr/rustydns",
"path": "/tests/dnslabel_tests.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
fn hash_label(s: &str) ->u64 {
let mut hasher = DefaultHasher::new();
Label::from_str(s).ok().unwrap().hash(&mut hasher);
hasher.finish()
}
#[test]
fn check_label_hash() {
assert!(hash_label("") == hash_label... | code_fim | hard | {
"lang": "rust",
"repo": "vidarr/rustydns",
"path": "/tests/dnslabel_tests.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn as_sequence(self) -> ASN1Result<Sequence> {
match self {
ASN1Value::Sequence(v) => Ok(v),
ASN1Value::Trap(v) => Ok(v),
_ => Err(Error::WrongType)
}
}
}
fn read_tag_value(reader: &mut ASN1Reader) -> ASN1Result<(ASN1Type, usize)> {
let ... | code_fim | hard | {
"lang": "rust",
"repo": "ibawt/trapdoor",
"path": "/src/asn1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ibawt/trapdoor path: /src/asn1.rs
use std::error;
use std::io;
use std::io::prelude::*;
use byteorder;
use bit_vec::BitVec;
use std::net::{Ipv4Addr,IpAddr, Ipv6Addr};
use std::fmt;
use std::string;
use byteorder::{BigEndian, ReadBytesExt};
#[derive(Debug)]
pub enum Error {
Io(io::Error),
... | code_fim | hard | {
"lang": "rust",
"repo": "ibawt/trapdoor",
"path": "/src/asn1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cscheid/loom path: /src/material.rs
use ray::Ray;
use vector::Vec3;
use hitable::HitRecord;
use std::fmt;
//////////////////////////////////////////////////////////////////////////////
pub enum Scatter {
Bounce(Vec3, Ray),
Emit(Vec3),
Absorb
}
pub trait Material: Send + Sync {
... | code_fim | medium | {
"lang": "rust",
"repo": "cscheid/loom",
"path": "/src/material.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Debug for Material {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.debug(f)
}
}<|fim_prefix|>// repo: cscheid/loom path: /src/material.rs
use ray::Ray;
use vector::Vec3;
use hitable::HitRecord;
use std::fmt;
////////////////////////////////////////////////////////... | code_fim | hard | {
"lang": "rust",
"repo": "cscheid/loom",
"path": "/src/material.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ray_in: &Ray,
ray_out: &Ray,
surface_normal: &Vec3) -> Vec3;
fn bsdf(&self,
ray_in: &Ray,
ray_out: &Ray,
surface_normal: &Vec3) -> f64;
fn scatter(&self, ray_in: &Ray, hit_record: &HitRecord) -> Scatter;
fn debug(&se... | code_fim | medium | {
"lang": "rust",
"repo": "cscheid/loom",
"path": "/src/material.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Adds any heap blocks and string values found in embedded values to the given set.
#[logfn_inputs(TRACE)]
pub fn record_heap_blocks_and_strings(&self, result: &mut HashSet<Rc<AbstractValue>>) {
match &self.value {
PathEnum::QualifiedPath {
qualifier,
... | code_fim | hard | {
"lang": "rust",
"repo": "facebookexperimental/MIRAI",
"path": "/checker/src/path.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebookexperimental/MIRAI path: /checker/src/path.rs
omputed path may be an alias for other paths, so remember to do weak updates
/// when using a computed path as key in the environment. When reading, remember to abstract
/// over the values from all paths that may alias this path.
... | code_fim | hard | {
"lang": "rust",
"repo": "facebookexperimental/MIRAI",
"path": "/checker/src/path.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Creates a path the qualifies the given root path with the given selector.
#[logfn_inputs(TRACE)]
pub fn new_qualified(qualifier: Rc<Path>, selector: Rc<PathSelector>) -> Rc<Path> {
if let PathEnum::Computed { value } = &qualifier.value {
// A path to bottom must stay th... | code_fim | hard | {
"lang": "rust",
"repo": "facebookexperimental/MIRAI",
"path": "/checker/src/path.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: Texture, F: Font<Texture = T>> Assets<T, F> {
pub fn load(
world: &GamePlay,
asset_manager: &mut impl asset::Manager<Texture = T, Font = F>,
) -> Result<Self> {
match *world {
GamePlay::Running(ref world) => {
running::Assets::load(world,... | code_fim | hard | {
"lang": "rust",
"repo": "nrxus/engine_duck",
"path": "/src/game/game_play/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nrxus/engine_duck path: /src/game/game_play/mod.rs
mod running;
mod timeup;
use self::{running::Running, timeup::TimeUp};
use crate::{asset, data::Animators, game::player, Result};
use moho::{self, engine::step::fixed, font::Font, input, texture::Texture};
use std::time::Duration;
pub enum G... | code_fim | medium | {
"lang": "rust",
"repo": "nrxus/engine_duck",
"path": "/src/game/game_play/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(moho::Show)]
pub enum Assets<T, F> {
Running(running::Assets<T, F>),
TimeUp(timeup::Assets<T, F>),
}
impl<T: Texture, F: Font<Texture = T>> Assets<T, F> {
pub fn next(
self,
world: &GamePlay,
step: &fixed::State,
asset_manager: &mut impl asset::Manager... | code_fim | hard | {
"lang": "rust",
"repo": "nrxus/engine_duck",
"path": "/src/game/game_play/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut d: BigUint = One::one();
let mut n: BigUint = 2.to_biguint().unwrap();
for i in 2..101 {
let mut acc: BigUint = d;
let mut m: BigUint = if i % 3 == 0 { (2 * (i / 3)).to_biguint().unwrap() }
else { One::one() };
d = n;
n = m... | code_fim | medium | {
"lang": "rust",
"repo": "derrickbaldwin/euler-project",
"path": "/rust/problem_65/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: derrickbaldwin/euler-project path: /rust/problem_65/src/main.rs
#![feature(i128)]
#![feature(i128_type)]
extern crate problem_65;
extern crate num_traits;
extern crate num_bigint;
<|fim_suffix|>fn main() {
let mut d: BigUint = One::one();
let mut n: BigUint = 2.to_biguint().unwrap();
... | code_fim | medium | {
"lang": "rust",
"repo": "derrickbaldwin/euler-project",
"path": "/rust/problem_65/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Lenqth/pyo3-sandbox path: /src/iter.rs
#![feature(specialization)]
use pyo3::prelude::*;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::path::Path;
use pyo3::PyIterProtocol;
#[pyclass]
pub struct RowReader {
path: Box<Path>,
}
<|fim_suffix|> use std::p... | code_fim | hard | {
"lang": "rust",
"repo": "Lenqth/pyo3-sandbox",
"path": "/src/iter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut s = String::new();
let l = slf.file.read_line(&mut s)?;
if l == 0 {
Ok(None)
} else {
if s.chars().last().unwrap() == '\n' {
s.pop();
if s.chars().last().unwrap() == '\r' {
s.pop();
... | code_fim | medium | {
"lang": "rust",
"repo": "Lenqth/pyo3-sandbox",
"path": "/src/iter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (i, text) in entries.into_iter() {
if i == self.selected {
draw!(state.r; @bold @style: selected @loc: (4, (i as u16) + 3) -> "⮞ {}", &text?);
} else {
draw!(state.r; @style: default @loc: (6, (i as u16) + 3) -> "{}", &text?);
... | code_fim | hard | {
"lang": "rust",
"repo": "proctorlabs/ecli",
"path": "/src/screen/menus/choice.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn init(&self, state: &mut State) -> Result<()> {
let r = &mut state.r;
r.set_render_mode(RenderMode::Raw)?;
Ok(())
}
fn render(&self, state: &mut State) -> Result<()> {
let title = self.menu.title.render()?;
let entries: Vec<(usize, Result<String>)> = ... | code_fim | hard | {
"lang": "rust",
"repo": "proctorlabs/ecli",
"path": "/src/screen/menus/choice.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: proctorlabs/ecli path: /src/screen/menus/choice.rs
use super::*;
#[derive(Debug)]
pub struct ChoiceScreen {
pub menu: ChoiceMenu,
pub selected: usize,
}
impl ChoiceScreen {
#[allow(clippy::new_ret_no_self)]
pub fn new(menu: ChoiceMenu) -> Result<Box<dyn Screen>> {
Ok(Bo... | code_fim | hard | {
"lang": "rust",
"repo": "proctorlabs/ecli",
"path": "/src/screen/menus/choice.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::SystemData::setup(res);
self.reader = Some(res.fetch_mut::<OnPlayerJoin>().register_reader());
}
fn run(&mut self, data: Self::SystemData) {
for evt in data.join_channel.read(self.reader.as_mut().unwrap()) {
(&data.pos, &data.team, &data.carrier, &data.is_flag)
.join()
.for_each... | code_fim | hard | {
"lang": "rust",
"repo": "Phantomical/mighty-server",
"path": "/ctf/src/systems/loginupdate.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn run(&mut self, data: Self::SystemData) {
for evt in data.join_channel.read(self.reader.as_mut().unwrap()) {
(&data.pos, &data.team, &data.carrier, &data.is_flag)
.join()
.for_each(|(pos, team, carrier, _)| {
let ty = match carrier.0 {
Some(_) => FlagUpdateType::Carrier,
N... | code_fim | hard | {
"lang": "rust",
"repo": "Phantomical/mighty-server",
"path": "/ctf/src/systems/loginupdate.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Phantomical/mighty-server path: /ctf/src/systems/loginupdate.rs
use specs::*;
use server::component::channel::*;
use server::protocol::server::{GameFlag, ServerPacket};
use server::protocol::{to_bytes, FlagUpdateType};
use server::*;
use component::*;
pub struct LoginUpdateSystem {
reader: O... | code_fim | hard | {
"lang": "rust",
"repo": "Phantomical/mighty-server",
"path": "/ctf/src/systems/loginupdate.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Azure/azure-sdk-for-rust path: /services/mgmt/storsimple1200series/src/package_2016_10/mod.rs
RequestBuilder {
client: self.0.clone(),
credential_name: credential_name.into(),
subscription_id: subscription_id.into(),
resource_group_... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/azure-sdk-for-rust",
"path": "/services/mgmt/storsimple1200series/src/package_2016_10/mod.rs",
"mode": "psm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: medmedmedic/isar-core path: /dart-ffi/src/instance.rs
use crate::dart::dart_post_int;
use crate::dart::DartPort;
use crate::error::DartErrCode;
use crate::from_c_str;
use crate::txn::run_async;
use isar_core::collection::IsarCollection;
use isar_core::error::{illegal_arg, Result};
use isar_core:... | code_fim | hard | {
"lang": "rust",
"repo": "medmedmedic/isar-core",
"path": "/dart-ffi/src/instance.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_async(
move || match open(name, dir, max_size as usize, schema_json, encryption_key) {
Ok(instance) => {
isar.0.write(instance.as_ref());
dart_post_int(port, 0);
}
Err(e) => {
dart_post_int(port, e.into_dar... | code_fim | hard | {
"lang": "rust",
"repo": "medmedmedic/isar-core",
"path": "/dart-ffi/src/instance.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/clang-sys/src/support.rs
use
std
:
:
path
:
:
{
Path
PathBuf
}
;
use
std
:
:
process
:
:
Command
;
use
std
:
:
{
env
io
}
;
use
glob
:
:
{
self
Pattern
}
;
use
libc
:
:
c_int
;
use
super
:
:
CXVersion
;
#
[
derive
(
Clone
D... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/clang-sys/src/support.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>_
)
|
o
)
}
fn
parse_version_number
(
number
:
&
str
)
-
>
Option
<
c_int
>
{
number
.
chars
(
)
.
take_while
(
|
c
|
c
.
is_digit
(
10
)
)
.
collect
:
:
<
String
>
(
)
.
parse
(
)
.
ok
(
)
}
fn
parse_version
(
path
:
&
Path
)
-
>
Option
<
CXVersion
>
{
let
output
=
run_clang
(
path
&
[
"
-
-
version
"
]
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified-and-comments-removed",
"path": "/third_party/rust/clang-sys/src/support.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> d.visit_children_with(self);
if let DeclarationName::Ident(name) = &d.name {
if &*name.value == "composes" {
// composes: name from 'foo.css'
if d.value.len() >= 3 {
if let (
ComponentValue::Ident(box ... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_css_modules/src/imports.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_css_modules/src/imports.rs
//! Import/export analyzer
use swc_atoms::{js_word, JsWord};
use swc_css_ast::{
ComponentValue, Declaration, DeclarationName, Ident, ImportHref, ImportPrelude, Stylesheet,
UrlValue,
};
use swc_css_visit::{Visit, VisitWith};
<... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_css_modules/src/imports.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> for blk_digest in self.idx_tips.iter() {
if self.tie_break(blk_digest, max_height_tip) == blk_digest
&& self.is_prefix_of(blk_checkpoint, blk_digest).expect("unexpected error in comparing blocks") {
max_height_tip = blk_digest;
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "joachimneu/accountability-gadget-prototype",
"path": "/mynode/src/lcblocks.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> bincode::deserialize::<LcBlock>(&value)
}
}
impl TryFrom<&LcBlock> for Vec<u8> {
type Error = Box<bincode::ErrorKind>;
fn try_from(value: &LcBlock) -> Result<Self, Self::Error> {
bincode::serialize(&value)
}
}
impl Hash for LcBlock {
fn digest(&self) -> Digest {
... | code_fim | hard | {
"lang": "rust",
"repo": "joachimneu/accountability-gadget-prototype",
"path": "/mynode/src/lcblocks.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joachimneu/accountability-gadget-prototype path: /mynode/src/lcblocks.rs
use serde::{Deserialize, Serialize};
use crypto::{Digest, Hash};
use ed25519_dalek::{Sha512, Digest as _};
use std::convert::{TryFrom, TryInto};
use std::collections::{HashMap, HashSet};
use std::fmt;
// LC BLOCK PAYLOAD
... | code_fim | hard | {
"lang": "rust",
"repo": "joachimneu/accountability-gadget-prototype",
"path": "/mynode/src/lcblocks.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.progress_bar.set_length(dltotal as u64);
self.progress_bar.set_position(dlnow as u64);
true
}
}
impl DownloadToBuffer {
fn purge(&mut self) -> Vec<u8> {
mem::replace(&mut self.data, Vec::new())
}
}
fn download(url: &str, progress_bar: ProgressBar) -> Resu... | code_fim | hard | {
"lang": "rust",
"repo": "fulmicoton/tantivy-ccrawl",
"path": "/indexer/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fulmicoton/tantivy-ccrawl path: /indexer/src/main.rs
extern crate curl;
extern crate structopt;
extern crate structopt_derive;
#[macro_use]
extern crate log;
extern crate env_logger;
#[macro_use]
extern crate tantivy;
extern crate chan;
extern crate flate2;
extern crate futures;
extern crate in... | code_fim | hard | {
"lang": "rust",
"repo": "fulmicoton/tantivy-ccrawl",
"path": "/indexer/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>extern crate ci_info;
extern crate clap;
extern crate fern;
extern crate glob;
#[macro_use]
extern crate log;
extern crate rand;
extern crate run_script;
extern crate rust_info;
extern crate semver;
#[macro_use]
extern crate serde_derive;
extern crate shell2batch;
extern crate toml;
// make types public ... | code_fim | hard | {
"lang": "rust",
"repo": "kostko/cargo-make",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kostko/cargo-make path: /src/main.rs
#![deny(anonymous_parameters, coerce_never, const_err, dead_code, deprecated, exceeding_bitshifts,
illegal_floating_point_literal_pattern, improper_ctypes, incoherent_fundamental_impls,
invalid_type_param_default, late_bound_lifetime_arguments... | code_fim | hard | {
"lang": "rust",
"repo": "kostko/cargo-make",
"path": "/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) struct WebScriptState {
context: JsValue,
on_enter: Option<Function>,
on_process: Option<Function>,
on_exit: Option<Function>,
}
impl WebScriptState {
pub fn new(context: JsValue) -> Self {
let on_enter = if let Ok(m) = Reflect::get(&context, &JsValue::from_str("onE... | code_fim | hard | {
"lang": "rust",
"repo": "rustyforks/Oxygengine",
"path": "/oxygengine-script-web/src/state.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustyforks/Oxygengine path: /oxygengine-script-web/src/state.rs
use crate::interface::WebScriptInterface;
use core::{
ecs::World,
state::{State, StateChange},
};
use js_sys::{Function, JsString, Reflect};
use wasm_bindgen::{JsCast, JsValue};
pub trait WebScriptStateScripted {
fn on_... | code_fim | hard | {
"lang": "rust",
"repo": "rustyforks/Oxygengine",
"path": "/oxygengine-script-web/src/state.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(name) = self.inner.on_process(world) {
if let Some(result) = WebScriptInterface::build_state(&name) {
return StateChange::Swap(Box::new(WebScriptState::new(result)));
} else if let Some(result) = WebScriptInterface::build_state_scripted(&name) {
... | code_fim | hard | {
"lang": "rust",
"repo": "rustyforks/Oxygengine",
"path": "/oxygengine-script-web/src/state.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn ne(&self, rhs: &Address<S>) -> bool {
match *self {
Size::Unbounded => false,
Size::Bounded(ref n) => n.eq(rhs),
}
}
}
impl<S: SectorSize> PartialOrd for Size<S> {
fn partial_cmp(&self, rhs: &Self) -> Option<Ordering> {
match (self, rhs) {
... | code_fim | hard | {
"lang": "rust",
"repo": "qinghe-os/ext2-rs",
"path": "/src/volume/size.rs",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qinghe-os/ext2-rs path: /src/volume/size.rs
use core::cmp::Ordering;
use core::fmt::{self, Display};
use sector::{Address, SectorSize};
#[derive(Clone, Copy, Debug, Hash)]
pub enum Size<S: SectorSize> {
Unbounded,
Bounded(Address<S>),
}
impl<S: SectorSize> Size<S> {
pub fn try_len... | code_fim | hard | {
"lang": "rust",
"repo": "qinghe-os/ext2-rs",
"path": "/src/volume/size.rs",
"mode": "psm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvanotti/fuchsia-mirror path: /src/developer/ffx/plugins/debug/symbol-index/src/lib.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.
mod symbol_index;
use {
anyhow::Result,... | code_fim | hard | {
"lang": "rust",
"repo": "mvanotti/fuchsia-mirror",
"path": "/src/developer/ffx/plugins/debug/symbol-index/src/lib.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn generate(cmd: GenerateCommand) -> Result<()> {
let mut index = SymbolIndex::new();
let build_dir = cmd.build_dir;
index.build_id_dirs = cmd
.build_id_dir
.into_iter()
.map(|path| BuildIdDir { path, build_dir: build_dir.clone() })
.collect();
index.ids_txt... | code_fim | hard | {
"lang": "rust",
"repo": "mvanotti/fuchsia-mirror",
"path": "/src/developer/ffx/plugins/debug/symbol-index/src/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Test add.
add(AddCommand { build_dir: None, path: ids_txt.clone() }, &index_path).unwrap();
add(AddCommand { build_dir: build_dir.clone(), path: build_id_dir.clone() }, &index_path)
.unwrap();
// Duplicated adding should be a noop
add(AddCommand { bui... | code_fim | hard | {
"lang": "rust",
"repo": "mvanotti/fuchsia-mirror",
"path": "/src/developer/ffx/plugins/debug/symbol-index/src/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod load_event_target;
pub use self::load_event_target::*;<|fim_prefix|>// repo: RSSchermer/ARWA path: /arwa/src/loading/mod.rs
mod error_event;
pub use self::error_event::*;
<|fim_middle|>mod load_event;
pub use self::load_event::*;
| code_fim | easy | {
"lang": "rust",
"repo": "RSSchermer/ARWA",
"path": "/arwa/src/loading/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RSSchermer/ARWA path: /arwa/src/loading/mod.rs
mod error_event;
pub use self::error_event::*;
<|fim_suffix|>mod load_event_target;
pub use self::load_event_target::*;<|fim_middle|>mod load_event;
pub use self::load_event::*;
| code_fim | easy | {
"lang": "rust",
"repo": "RSSchermer/ARWA",
"path": "/arwa/src/loading/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Arnavion/k8s-openapi path: /src/v1_26/api/core/v1/service_spec.rs
bernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
///
pub session_affinity: Option<String>,
/// sessionAffinityConfig contains the configurations of session affinity.
pub sessi... | code_fim | hard | {
"lang": "rust",
"repo": "Arnavion/k8s-openapi",
"path": "/src/v1_26/api/core/v1/service_spec.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Arnavion/k8s-openapi path: /src/v1_26/api/core/v1/service_spec.rs
e (in which case this field may optionally be specified, as describe above). Valid values are "None", empty string (""), or a valid IP address. Setting this to "None" makes a "headless service" (no virtual IP), which is useful w... | code_fim | hard | {
"lang": "rust",
"repo": "Arnavion/k8s-openapi",
"path": "/src/v1_26/api/core/v1/service_spec.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
"ريتال",
"ريف",
"ريفال",
"ريم",
"ريما",
"ريمان",
"ريناد",
"زكية",
"زهرة",
"سبأ",
"سجى",
"سديم",
"سلاف",
"سلسبيل",
"شادن",
"شهد",
"ضحى",
"ضياء",
"عالية",
... | code_fim | hard | {
"lang": "rust",
"repo": "cksac/fake-rs",
"path": "/fake/src/locales/ar_sa.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cksac/fake-rs path: /fake/src/locales/ar_sa.rs
use crate::locales::Data;
#[allow(non_camel_case_types)]
#[derive(Copy, Clone)]
pub struct AR_SA;
impl Data for AR_SA {
const NAME_FIRST_NAME: &'static [&'static str] = &[
"آلاء",
"آيات",
"أجوان",
"أحلام",
... | code_fim | hard | {
"lang": "rust",
"repo": "cksac/fake-rs",
"path": "/fake/src/locales/ar_sa.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !self.is_pressed(code) {
self.keys.push(code);
}
}
fn remove_key(&mut self, code: VirtualKeyCode) {
if let Some(index) = self.keys.iter().position(|x| *x == code) {
self.keys.remove(index);
}
}
pub fn update(&mut self, code: VirtualKeyCode, state: ElementState) {
match state {
... | code_fim | hard | {
"lang": "rust",
"repo": "VictorKoenders/rust_game",
"path": "/client/src/game_state.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VictorKoenders/rust_game path: /client/src/game_state.rs
use glium::glutin::{VirtualKeyCode, ElementState, MouseButton, CursorState};
use vecmath::{Vector2, Vector3, vec3_normalized, vec3_square_len};
use model::Model;
use std::fmt::{Debug, Formatter, Error as DebugError};
// TODO: attach a mov... | code_fim | hard | {
"lang": "rust",
"repo": "VictorKoenders/rust_game",
"path": "/client/src/game_state.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn update(&mut self, delta_time: f32) {
if let Some(ref mut player) = self.player {
let mut transformation = [0.0f32, 0.0f32, 0.0f32];
let mut rotation = [0.0f32, 0.0f32, 0.0f32];
if self.keyboard.is_pressed(VirtualKeyCode::A) {
transformation[0] -= 1.0f32;
}
if self.keyboard.is... | code_fim | hard | {
"lang": "rust",
"repo": "VictorKoenders/rust_game",
"path": "/client/src/game_state.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jamescarterbell/bloxel path: /src/renderer.rs
_err(|_| "Couldn't open the PhysicalDevice!")?
};
let queue_group = queues
.take::<Graphics>(queue_family.id())
.ok_or("Couldn't take ownership of the QueueGroup!")?;
let _ = if queu... | code_fim | hard | {
"lang": "rust",
"repo": "jamescarterbell/bloxel",
"path": "/src/renderer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Recreate and assing swapchain
self.swapchain = ManuallyDrop::new(swapchain);
self.image_views = backbuffer
.into_iter()
.map(|image| unsafe {
self.device
.create_image_view(
&image,
... | code_fim | hard | {
"lang": "rust",
"repo": "jamescarterbell/bloxel",
"path": "/src/renderer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.image_views = backbuffer
.into_iter()
.map(|image| unsafe {
self.device
.create_image_view(
&image,
ViewKind::D2,
format,
Swizzle::NO,
... | code_fim | hard | {
"lang": "rust",
"repo": "jamescarterbell/bloxel",
"path": "/src/renderer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>te::Readable for AREF_CTRL {}
#[doc = "`write(|w| ..)` method takes [aref_ctrl::W](aref_ctrl::W) writer structure"]
impl crate::Writable for AREF_CTRL {}
#[doc = "global AREF control"]
pub mod aref_ctrl;<|fim_prefix|>// repo: mvertescher/psoc6-pac path: /src/pass/aref.rs
#[doc = "global AREF control\n\nT... | code_fim | hard | {
"lang": "rust",
"repo": "mvertescher/psoc6-pac",
"path": "/src/pass/aref.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mvertescher/psoc6-pac path: /src/pass/aref.rs
#[doc = "global AREF control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic<|fim_suffix|>"]
pub type AREF_CTRL = crate::Re... | code_fim | hard | {
"lang": "rust",
"repo": "mvertescher/psoc6-pac",
"path": "/src/pass/aref.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> (self.seed.0 >> (48 - bits)) as u32
}
#[allow(clippy::cast_lossless)]
/// Return a new int
pub fn next_int(&mut self, bound: u32) -> u32 {
assert!(bound > 0, "bound must be positive");
if bound.count_ones() == 1 {
((bound as u64 * self.next(31) as u64) >... | code_fim | hard | {
"lang": "rust",
"repo": "LFalch/java-utils",
"path": "/src/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LFalch/java-utils path: /src/util.rs
use std::num::Wrapping;
/// A `java.util.Random` implementation that implements the logic from Java in pure Rust.
pub struct Random {
seed: Wrapping<u64>,
}
<|fim_suffix|> (self.seed.0 >> (48 - bits)) as u32
}
#[allow(clippy::cast_lossles... | code_fim | hard | {
"lang": "rust",
"repo": "LFalch/java-utils",
"path": "/src/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maksym-pasichnyk/mcworld path: /src/pos.rs
use crate::raw::SubchunkPos;
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct ChunkPos {
pub x: i32,
pub z: i32,
pub dimension: Dimension,
}
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
... | code_fim | hard | {
"lang": "rust",
"repo": "maksym-pasichnyk/mcworld",
"path": "/src/pos.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let k = k as i32;
let div = n / k;
let rem = n - div * k;
// no need for fancy rounding if the remainder is 0
if rem == 0 {
return div;
}
// otherwise fix up the negative numbers to make the rounding go to negative
// infinity instead of zero
if n < 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "maksym-pasichnyk/mcworld",
"path": "/src/pos.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub enum Dimension {
Overworld = 0,
Nether = 1,
End = 2,
}
fn flooring_divide(n: i32, k: u32) -> i32 {
let k = k as i32;
let div = n / k;
let rem = n - div * k;
// no need for fancy rounding if the remainder ... | code_fim | hard | {
"lang": "rust",
"repo": "maksym-pasichnyk/mcworld",
"path": "/src/pos.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: b8591340/coreml path: /src/ml_feature_value_ml_image_conversion.rs
use crate::prelude::*;
// #import <CoreML/MLFeatureValue.h>
// #import <CoreML/MLImageConstraint.h>
// #import <CoreGraphics/CGImage.h>
// #import <ImageIO/CGImageProperties.h>
// #import <Foundation/NSURL.h>
// NS_ASSUME_NONNUL... | code_fim | hard | {
"lang": "rust",
"repo": "b8591340/coreml",
"path": "/src/ml_feature_value_ml_image_conversion.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// /// Construct image feature value from an image on disk using a model specified image constraint. The passed in orientation supersedes any in the file
// + (nullable instancetype)featureValueWithImageAtURL:(NSURL *)url
// orientation:(CGImagePropertyOrientation)o... | code_fim | hard | {
"lang": "rust",
"repo": "b8591340/coreml",
"path": "/src/ml_feature_value_ml_image_conversion.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/arc148/src/bin/b.rs
use proconio::{input, marker::Chars};
fn main() {
input! {
n: usize,
s: Chars,
};
match s.iter().position(|s_i| s_i == &'p') {
None => {
println!("{}", s.into_iter().collect::<... | code_fim | hard | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/arc148/src/bin/b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>t::<String>()
};
let mut ans = s.iter().collect::<String>();
for r in l..n {
ans = ans.min(f(r));
}
println!("{}", ans);
}
}
}<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/arc148/src/bin/b.... | code_fim | hard | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/arc148/src/bin/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danhper/diem path: /testsuite/forge/src/backend/local/mod.rs
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{Factory, Result, Swarm, Version};
use anyhow::Context;
use rand::rngs::StdRng;
use std::{
collections::HashMap,
num::NonZeroUsize,
... | code_fim | hard | {
"lang": "rust",
"repo": "danhper/diem",
"path": "/testsuite/forge/src/backend/local/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Create a LocalFactory with a diem-node version built at merge-base of upstream/main and the
/// current workspace, suitable for compatibility testing.
pub fn with_upstream_merge_base_and_workspace() -> Result<Self> {
let upstream_main = cargo::git_get_upstream_remote().map(|r| form... | code_fim | hard | {
"lang": "rust",
"repo": "danhper/diem",
"path": "/testsuite/forge/src/backend/local/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn new_swarm<R>(&self, rng: R, number_of_validators: NonZeroUsize) -> Result<LocalSwarm>
where
R: ::rand::RngCore + ::rand::CryptoRng,
{
let version = self.versions.keys().max().unwrap();
self.new_swarm_with_version(rng, number_of_validators, version)
}
pub... | code_fim | hard | {
"lang": "rust",
"repo": "danhper/diem",
"path": "/testsuite/forge/src/backend/local/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: asciiu/discipline path: /src/models/mod.rs
use crate::schema::users;
use chrono::{NaiveDateTime};
use uuid::Uuid;
<|fim_suffix|>#[derive(Insertable)]
#[table_name="users"]
pub struct NewUser<'a> {
pub id: Uuid,
pub email: &'a str,
pub username: &'a str,
pub password_hash: &'a st... | code_fim | hard | {
"lang": "rust",
"repo": "asciiu/discipline",
"path": "/src/models/mod.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Insertable)]
#[table_name="users"]
pub struct NewUser<'a> {
pub id: Uuid,
pub email: &'a str,
pub username: &'a str,
pub password_hash: &'a str,
}<|fim_prefix|>// repo: asciiu/discipline path: /src/models/mod.rs
use crate::schema::users;
use chrono::{NaiveDateTime};
use uuid::Uui... | code_fim | hard | {
"lang": "rust",
"repo": "asciiu/discipline",
"path": "/src/models/mod.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, T: 'a + StrLike + ?Sized> Iterator for Iter<'a, T> {
type Item = &'a T;
fn next(&mut self) -> Option<&'a T> {
if self.idx < self.split.len() {
let ret = unsafe {
T::from_data_unchecked(self.split.get(self.idx).index_into(self.buffer))
};
... | code_fim | hard | {
"lang": "rust",
"repo": "nox/multistr",
"path": "/src/iter.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nox/multistr path: /src/iter.rs
use super::{Split, StrLike};
/// Iterator over `Dynamic` and `Static` types.
pub struct Iter<'a, T: 'a + StrLike + ?Sized> {
buffer: &'a T::Data,
split: Split<'a>,
idx: usize,
}
impl<'a, T: 'a + StrLike + ?Sized> Iter<'a, T> {
pub(crate) fn new(bu... | code_fim | hard | {
"lang": "rust",
"repo": "nox/multistr",
"path": "/src/iter.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.idx < self.split.len() {
let ret = unsafe {
T::from_data_unchecked(self.split.get(self.idx).index_into(self.buffer))
};
self.idx += 1;
Some(ret)
} else {
None
}
}
}<|fim_prefix|>// repo: nox/mul... | code_fim | hard | {
"lang": "rust",
"repo": "nox/multistr",
"path": "/src/iter.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JohnDoneth/coffee path: /src/graphics/canvas.rs
use crate::graphics::gpu::{self, texture, Gpu};
use crate::graphics::{IntoQuad, Target};
use crate::load::Task;
use crate::Result;
/// An off-screen rendering target.
///
/// It can be used both as a [`Target`] and as a resource.
///
/// [`Target`... | code_fim | hard | {
"lang": "rust",
"repo": "JohnDoneth/coffee",
"path": "/src/graphics/canvas.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Views the [`Canvas`] as a [`Target`].
///
/// [`Canvas`]: struct.Canvas.html
/// [`Target`]: struct.Target.html
pub fn as_target<'a>(&'a mut self, gpu: &'a mut Gpu) -> Target<'a> {
let texture = self.drawable.texture();
Target::with_transformation(
gpu,... | code_fim | hard | {
"lang": "rust",
"repo": "JohnDoneth/coffee",
"path": "/src/graphics/canvas.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Reads the pixels of the [`Canvas`].
///
/// _Note:_ This is a very slow operation.
///
/// [`Canvas`]: struct.Canvas.html
pub fn read_pixels(&self, gpu: &mut Gpu) -> image::DynamicImage {
gpu.read_drawable_texture_pixels(&self.drawable)
}
}
impl std::fmt::Debug for... | code_fim | hard | {
"lang": "rust",
"repo": "JohnDoneth/coffee",
"path": "/src/graphics/canvas.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, PartialEq, Eq, Hash)]
enum MemOp {
Return(Value),
Ignore,
Fence(Fence),
Read(Loc, bool),
Write(Loc, bool, Value),
Update(Loc, bool),
CommitUpdate(Loc, bool, Value),
CancelUpdate(Loc),
}
impl<'a> InState<'a> {
fn push(&mut self, v: Value) {
self.... | code_fim | hard | {
"lang": "rust",
"repo": "cham7irxc5zb/understanding-memory-models",
"path": "/src/tlang/eval.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, PartialEq, Eq, Hash)]
pub struct UpdateState<'a> {
then: InState<'a>,
}
#[derive(Clone, PartialEq, Eq, Hash)]
enum MemOp {
Return(Value),
Ignore,
Fence(Fence),
Read(Loc, bool),
Write(Loc, bool, Value),
Update(Loc, bool),
CommitUpdate(Loc, bool, Value),
... | code_fim | hard | {
"lang": "rust",
"repo": "cham7irxc5zb/understanding-memory-models",
"path": "/src/tlang/eval.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cham7irxc5zb/understanding-memory-models path: /src/tlang/eval.rs
use super::{Inst, Proc, Reg, Value};
use crate::index::*;
use crate::memory::Loc;
use crate::program::{compiler, Fence};
use std::{hash, ptr};
#[derive(Clone)]
struct InState<'a> {
prog: &'a Proc,
inst: usize,
updatin... | code_fim | hard | {
"lang": "rust",
"repo": "cham7irxc5zb/understanding-memory-models",
"path": "/src/tlang/eval.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn print() {
print!("{}", Cwd::get());
}
}<|fim_prefix|>// repo: webian-dart/butler path: /src/subtasks/cwd.rs
use std::env;
pub struct Cwd {}
<|fim_middle|>impl Cwd {
pub(crate) fn get() -> String {
env::current_dir().unwrap().to_str().unwrap().to_owned()
}
| code_fim | medium | {
"lang": "rust",
"repo": "webian-dart/butler",
"path": "/src/subtasks/cwd.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: webian-dart/butler path: /src/subtasks/cwd.rs
use std::env;
pub struct Cwd {}
<|fim_suffix|> pub(crate) fn print() {
print!("{}", Cwd::get());
}
}<|fim_middle|>impl Cwd {
pub(crate) fn get() -> String {
env::current_dir().unwrap().to_str().unwrap().to_owned()
}
| code_fim | medium | {
"lang": "rust",
"repo": "webian-dart/butler",
"path": "/src/subtasks/cwd.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.