text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: jolestar/libra path: /language/borrow-graph/src/graph.rs
ve(Clone, Debug, Default, PartialEq)]
pub struct BorrowGraph<Loc: Copy, Lbl: Clone + Ord>(BTreeMap<RefID, Ref<Loc, Lbl>>);
//**************************************************************************************************
// Impls
//***... | code_fim | hard | {
"lang": "rust",
"repo": "jolestar/libra",
"path": "/language/borrow-graph/src/graph.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0.iter().all(|(id, r)| {
r.borrowed_by.0.keys().all(|to_id| id != to_id)
&& r.borrows_from.iter().all(|from_id| id != from_id)
})
}
//**********************************************************************************************
// Util
//*... | code_fim | hard | {
"lang": "rust",
"repo": "jolestar/libra",
"path": "/language/borrow-graph/src/graph.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// checks if `self` covers `other`
pub fn leq(&self, other: &Self) -> bool {
self.unmatched_edges(other).is_empty()
}
fn unmatched_edges(&self, other: &Self) -> BTreeMap<RefID, BorrowEdges<Loc, Lbl>> {
let mut unmatched_edges = BTreeMap::new();
for (parent_id, oth... | code_fim | hard | {
"lang": "rust",
"repo": "jolestar/libra",
"path": "/language/borrow-graph/src/graph.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
#[ad_function] // It generates `f_ad: AD -> AD` automatically
fn f(x: f64) -> f64 {
x.exp() - (x + 2f64)
}<|fim_prefix|>// repo: Axect/Peroxide_Gallery path: /Numeric/root_finding_macro/src/main.rs
use peroxide::fuga::*;
fn main() -> Result<(), RootError> {
<|fim_middle|> let x = ne... | code_fim | medium | {
"lang": "rust",
"repo": "Axect/Peroxide_Gallery",
"path": "/Numeric/root_finding_macro/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Axect/Peroxide_Gallery path: /Numeric/root_finding_macro/src/main.rs
use peroxide::fuga::*;
fn main() -> Result<(), RootError> {
<|fim_suffix|>#[ad_function] // It generates `f_ad: AD -> AD` automatically
fn f(x: f64) -> f64 {
x.exp() - (x + 2f64)
}<|fim_middle|> let x = newton(f_ad, 1f6... | code_fim | medium | {
"lang": "rust",
"repo": "Axect/Peroxide_Gallery",
"path": "/Numeric/root_finding_macro/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> x.exp() - (x + 2f64)
}<|fim_prefix|>// repo: Axect/Peroxide_Gallery path: /Numeric/root_finding_macro/src/main.rs
use peroxide::fuga::*;
fn main() -> Result<(), RootError> {
let x = newton(f_ad, 1f64, 100, 1e-15)?;
x.print();
Ok(())
}
<|fim_middle|>#[ad_function] // It generates `f_ad:... | code_fim | medium | {
"lang": "rust",
"repo": "Axect/Peroxide_Gallery",
"path": "/Numeric/root_finding_macro/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ShabbirHasan1/sxg-rs path: /sxg_rs/src/http_parser/mod.rs
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache... | code_fim | medium | {
"lang": "rust",
"repo": "ShabbirHasan1/sxg-rs",
"path": "/sxg_rs/src/http_parser/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Error::msg(format!("{}", err))
}
// Parses a http header which might have multiple values separated by comma.
fn parse_vec<'a, F, T>(input: &'a str, parse_single: F) -> Result<Vec<T>>
where
F: Fn(&'a str) -> IResult<&'a str, T>,
{
let (input, items) =
separated_list0!(input, separated... | code_fim | medium | {
"lang": "rust",
"repo": "ShabbirHasan1/sxg-rs",
"path": "/sxg_rs/src/http_parser/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Blur the image with the given `Gaussian` sigma.
fn blur(&self, sigma: f32) -> Self::Buf;
/// Iterate over the image, passing each pixel's coordinates and values in `u8` to the closure.
///
/// The iteration order is unspecified but each pixel **must** be visited exactly _once_.
... | code_fim | hard | {
"lang": "rust",
"repo": "abonander/img_hash",
"path": "/src/traits.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.iter_mut().zip(other.iter()).for_each(|(l, r)| *l -= r);
}
}
impl Image for DynamicImage {
type Buf = image::RgbaImage;
fn to_grayscale(&self) -> Cow<GrayImage> {
self.as_luma8().map_or_else(|| Cow::Owned(self.to_luma()), Cow::Borrowed)
}
fn blur(&self, sigma: f... | code_fim | hard | {
"lang": "rust",
"repo": "abonander/img_hash",
"path": "/src/traits.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abonander/img_hash path: /src/traits.rs
use image::{imageops, DynamicImage, GenericImageView, GrayImage, ImageBuffer, Pixel};
use std::borrow::Cow;
use std::ops;
/// Interface for types used for storing hash data.
///
/// This is implemented for `Vec<u8>`, `Box<[u8]>` and arrays that are multi... | code_fim | hard | {
"lang": "rust",
"repo": "abonander/img_hash",
"path": "/src/traits.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: decafjoe/mgit path: /src/ui.rs
//! Common UI components.
use std::iter::Iterator;
use git2::{Branch, BranchType, Oid, Repository};
use app::Error;
// ----- Kind -----------------------------------------------------------------
/// Generic indicator for "result" or "status."
#[derive(Clone, P... | code_fim | hard | {
"lang": "rust",
"repo": "decafjoe/mgit",
"path": "/src/ui.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> TrackingBranches<'a> {
/// Creates and returns a new `TrackingBranches` iterator for the repository `git`.
pub fn for_repository(git: &'a Repository) -> Result<Self, Vec<Error>> {
match TrackingBranches::get(git) {
Ok(branches) => Ok(Self { branches }),
Err... | code_fim | hard | {
"lang": "rust",
"repo": "decafjoe/mgit",
"path": "/src/ui.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns the name of the local branch.
pub fn local_name(&self) -> String {
self.branch
.name()
.expect("failed to get name for local branch")
.expect("local branch name is not valid utf-8")
.to_owned()
}
/// Returns the oid of th... | code_fim | hard | {
"lang": "rust",
"repo": "decafjoe/mgit",
"path": "/src/ui.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return Response::text(format!(
"Invalid library! Use `{}dfm` to see usage & libraries.",
prefix,
));
},
};
let amount = library.items.len();
let tracks = library
.items
.ite... | code_fim | hard | {
"lang": "rust",
"repo": "Erk-/worker",
"path": "/src/commands/discordfm.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let query = ctx.args.join(" ").to_lowercase();
let library = match ctx.state.discord_fm.libraries.get(&query) {
Some(library) => library,
None => {
let prefix = ctx.prefix()?;
return Response::text(format!(
"Inva... | code_fim | hard | {
"lang": "rust",
"repo": "Erk-/worker",
"path": "/src/commands/discordfm.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Erk-/worker path: /src/commands/discordfm.rs
use super::prelude::*;
pub struct DfmCommand;
impl DfmCommand {
async fn _run(ctx: Context) -> CommandResult {
if ctx.args.is_empty() {
let prefix = ctx.prefix()?;
return Response::text(format!(
"... | code_fim | hard | {
"lang": "rust",
"repo": "Erk-/worker",
"path": "/src/commands/discordfm.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jespino/chip-u8 path: /src/ops.rs
#[derive(Debug)]
pub enum Opcode {
Rca(u16),
Clear,
Return,
Jump(u16),
JumpPlus(u16),
Call(u16),
SkipEqVal(u8, u8),
SkipNotEqVal(u8, u8),
SkipEq(u8, u8),
SetReg(u8, u8),
AddVal(u8, u8),
CopyReg(u8, u8),
And(u8,... | code_fim | hard | {
"lang": "rust",
"repo": "jespino/chip-u8",
"path": "/src/ops.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match op {
(0x0, 0x0, 0xE, 0x0) => Opcode::Clear,
(0x0, 0x0, 0xE, 0xE) => Opcode::Return,
(0x0, n1, n2, n3) => Opcode::Rca(((n1 as u16) << 8) + ((n2 as u16) << 4) + (n3 as u16)),
(0x1, n1, n2, n3) => Opcode::Jump(((n1 as u16) << 8) + ((n2 as u16) << 4) + (n3 as u16)),
... | code_fim | hard | {
"lang": "rust",
"repo": "jespino/chip-u8",
"path": "/src/ops.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NSWC-Crane/kerbx-flightsystems path: /utilities/flightplan-creator/src/main.rs
/*
* =================================================================================================
*
* PUBLIC DOMAIN NOTICE
* Naval Surface Warfare Ce... | code_fim | hard | {
"lang": "rust",
"repo": "NSWC-Crane/kerbx-flightsystems",
"path": "/utilities/flightplan-creator/src/main.rs",
"mode": "psm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Parse command line arguments.
let matches = App::new("KerbX Flightplan Created")
.version(env!("CARGO_PKG_VERSION"))
.author(env!("CARGO_PKG_AUTHORS"))
.about("Creates and saves a KerbX supported Flight Plan")
.arg(
Arg::with_name("output-file")
... | code_fim | medium | {
"lang": "rust",
"repo": "NSWC-Crane/kerbx-flightsystems",
"path": "/utilities/flightplan-creator/src/main.rs",
"mode": "spm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Now add our individual steps
let mut steps: Vec<Step> = Vec::new();
steps.push(gen_other_step(
1,
Step_ActionType::IGNITE,
gen_time_trigger(0),
));
let plan = gen_flightplan_from_steps(steps);
write_to_file(matches.value_of("output-file").unwrap(), &pl... | code_fim | hard | {
"lang": "rust",
"repo": "NSWC-Crane/kerbx-flightsystems",
"path": "/utilities/flightplan-creator/src/main.rs",
"mode": "spm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Pads list with a certain amount of zeros.
fn pad_list(l: Option<Box<Node<i32>>>, padding: usize) -> Option<Box<Node<i32>>> {
let mut head = l;
for _ in 0..padding {
head = Some(Box::new(Node {
data: 0,
next: head,
}));
}
head
}
#[cfg(test)]
mod ... | code_fim | hard | {
"lang": "rust",
"repo": "DarinM223/ctci-rs",
"path": "/src/chapter2/sum_lists.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DarinM223/ctci-rs path: /src/chapter2/sum_lists.rs
use super::Node;
/// This function is easiest to implement recursively.
/// The main difficulty is safely handling different sized lists.
pub fn sum_lists(
l1: Option<Box<Node<i32>>>,
l2: Option<Box<Node<i32>>>,
carry: i32,
) -> Opt... | code_fim | hard | {
"lang": "rust",
"repo": "DarinM223/ctci-rs",
"path": "/src/chapter2/sum_lists.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joeyahines/rfid-supply-chain path: /models/src/requests/update_record.rs
use serde::{Deserialize, Serialize};
use crate::central_record::CentralRecord;
use crate::rfid::RfidData;
use crate::BlockChainEntry;
use crate::{deserialize_base64, serialize_base64};
use byteorder::{BigEndian, WriteBytes... | code_fim | hard | {
"lang": "rust",
"repo": "joeyahines/rfid-supply-chain",
"path": "/models/src/requests/update_record.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> req
}
}
impl BlockChainEntry for UpdateRecordRequest {
fn signature(&self) -> Vec<u8> {
self.signature.clone()
}
}
impl Into<Vec<u8>> for UpdateRecordRequest {
fn into(self) -> Vec<u8> {
let mut bytes = Vec::new();
bytes.write_u32::<BigEndian>(self.dist_i... | code_fim | medium | {
"lang": "rust",
"repo": "joeyahines/rfid-supply-chain",
"path": "/models/src/requests/update_record.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl BlockChainEntry for UpdateRecordRequest {
fn signature(&self) -> Vec<u8> {
self.signature.clone()
}
}
impl Into<Vec<u8>> for UpdateRecordRequest {
fn into(self) -> Vec<u8> {
let mut bytes = Vec::new();
bytes.write_u32::<BigEndian>(self.dist_id).unwrap();
... | code_fim | medium | {
"lang": "rust",
"repo": "joeyahines/rfid-supply-chain",
"path": "/models/src/requests/update_record.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ingsuifon/411-rust-starter-code path: /src/middle/ir.rs
//! IR, or intermediate representation
use std::fmt;
use util::{Temp, TempAllocator};
pub struct Program {
pub statements: Vec<Statement>,
pub temps: TempAllocator,
}
#[derive(Clone)]
pub enum Statement {
Move(Expr, Expr),
... | code_fim | medium | {
"lang": "rust",
"repo": "Ingsuifon/411-rust-starter-code",
"path": "/src/middle/ir.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match *self {
Statement::Move(ref e1, ref e2) => write!(f, "{} <-- {}", e1, e2),
Statement::Return(ref e) => write!(f, "return {}", e),
}
}
}
impl fmt::Display for Expr {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
... | code_fim | hard | {
"lang": "rust",
"repo": "Ingsuifon/411-rust-starter-code",
"path": "/src/middle/ir.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn fetch_add(&self, val: u16) -> u16 {
let origin_val = self.shared.count.get();
self.shared.count.set(origin_val - val);
origin_val
}
}
#[derive(Debug)]
struct NotifyShared {
task: Rc<RefCell<Option<Task>>>,
count: Rc<Cell<u16>>,
expect: u16,
}
impl Clone... | code_fim | hard | {
"lang": "rust",
"repo": "shuinoo/aster",
"path": "/src/utils/notify.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shuinoo/aster path: /src/utils/notify.rs
use futures::task::Task;
use std::cell::{Cell, RefCell};
use std::rc::Rc;
#[derive(Debug, Clone)]
pub struct Notify {
shared: NotifyShared,
}
impl Notify {
pub fn empty() -> Self {
Notify {
shared: NotifyShared {
... | code_fim | hard | {
"lang": "rust",
"repo": "shuinoo/aster",
"path": "/src/utils/notify.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Sobert/camera-system path: /src/main.rs
use ggez::{graphics, Context, ContextBuilder, GameResult, timer};
use ggez::event::{self, EventHandler};
use ggez::graphics::{DrawParam};
use ggez::{nalgebra as na};
use ggez::event::{KeyCode, KeyMods};
use ggez::input::mouse::position;
use rand::Rng;
co... | code_fim | hard | {
"lang": "rust",
"repo": "Sobert/camera-system",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.keysdown.push(keycode);
self.keysdown.dedup_by_key(|x| *x);
}
fn key_up_event(&mut self, _ctx: &mut Context, keycode: KeyCode, _keymod: KeyMods) {
self.keysdown.retain(|&x| x != keycode);
}
fn mouse_wheel_event(&mut self, _ctx: &mut Context, _x: f32, y: f32) ... | code_fim | hard | {
"lang": "rust",
"repo": "Sobert/camera-system",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ProgramArguments {
pub fn parse() -> ProgramArguments {
argh::from_env()
}
}<|fim_prefix|>// repo: osphea/zircon-rpi path: /tools/affected_targets/src/argument_parsing.rs
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style... | code_fim | hard | {
"lang": "rust",
"repo": "osphea/zircon-rpi",
"path": "/tools/affected_targets/src/argument_parsing.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: osphea/zircon-rpi path: /tools/affected_targets/src/argument_parsing.rs
// Copyright 2020 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 argh::FromArgs;
<|fim_suffix|> /// the files that h... | code_fim | hard | {
"lang": "rust",
"repo": "osphea/zircon-rpi",
"path": "/tools/affected_targets/src/argument_parsing.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let value = match ExpressionFile::parse(text) {
Ok(x) => x,
Err(e) => return Ok((atoms::error(), format!("{}", e)).encode(env)),
};
let value = match ExpressionFile::eval(value, &mut Variables::default()) {
Ok(x) => x,
Err(e) => return Ok((atoms::error(), format... | code_fim | medium | {
"lang": "rust",
"repo": "thomas9911/expression_parser_polyglot",
"path": "/elixir/native/expression_parser_native/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thomas9911/expression_parser_polyglot path: /elixir/native/expression_parser_native/src/lib.rs
extern crate rustler;
use expression_parser::{ExpressionFile, Variables};
use rustler::{Encoder, Env, Error, Term};
<|fim_suffix|>rustler::rustler_export_nifs! {
"Elixir.ExpressionParserNative",
... | code_fim | medium | {
"lang": "rust",
"repo": "thomas9911/expression_parser_polyglot",
"path": "/elixir/native/expression_parser_native/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
grid = grid.step_all_directions();
steps += 1;
let next_occupied_seat_count = grid.occupied_seat_count();
if next_occupied_seat_count == occupied_seat_count || steps > 100 {
break occupied_seat_count;
} else {
occupied_seat_count ... | code_fim | hard | {
"lang": "rust",
"repo": "jasondew/advent-of-code",
"path": "/2020/rust/src/day11.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jasondew/advent-of-code path: /2020/rust/src/day11.rs
#[derive(Debug, PartialEq)]
enum Cell {
Floor,
EmptySeat,
OccupiedSeat,
}
#[derive(Debug)]
struct Grid {
data: Vec<Vec<Cell>>,
rows: usize,
cols: usize,
}
impl Grid {
fn step(&self) -> Grid {
let next_dat... | code_fim | hard | {
"lang": "rust",
"repo": "jasondew/advent-of-code",
"path": "/2020/rust/src/day11.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn list(session: Session) -> Result<Response<Body>, ServerError> {
let conn = session.context.db.lock();
let auths = DatabaseAssociation::list(&conn)?;
json_response(&auths)
}
pub async fn delete(id: i64, session: Session) -> Result<Response<Body>, ServerErr... | code_fim | hard | {
"lang": "rust",
"repo": "ShantanuNair/innernet",
"path": "/server/src/api/admin/association.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> json_response(&auths)
}
pub async fn delete(id: i64, session: Session) -> Result<Response<Body>, ServerError> {
let conn = session.context.db.lock();
DatabaseAssociation::delete(&conn, id)?;
status_response(StatusCode::NO_CONTENT)
}
}<|fim_prefix|>// repo: Sha... | code_fim | hard | {
"lang": "rust",
"repo": "ShantanuNair/innernet",
"path": "/server/src/api/admin/association.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ShantanuNair/innernet path: /server/src/api/admin/association.rs
//! A table to describe which CIDRs another CIDR is allowed to peer with.
//!
//! A peer belongs to one parent CIDR, and can by default see all peers within that parent.
use std::collections::VecDeque;
use crate::{
db::Databa... | code_fim | medium | {
"lang": "rust",
"repo": "ShantanuNair/innernet",
"path": "/server/src/api/admin/association.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Azure/iotedge path: /edgelet/iotedge/src/check/checks/mod.rs
mod aziot_edged_version;
mod check_agent_image;
mod connect_management_uri;
mod container_connect_upstream;
mod container_engine_dns;
mod container_engine_installed;
mod container_engine_ipv6;
mod container_engine_logrotate;
mod contai... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/iotedge",
"path": "/edgelet/iotedge/src/check/checks/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(output.stdout)
}
// built-in checks, as opposed to those that are deferred to `aziot check`
pub(crate) fn built_in_checks() -> [(&'static str, Vec<Box<dyn Checker>>); 2] {
/* Note: keep ordering consistent. Later tests may depend on earlier tests. */
[
(
"Configuration ... | code_fim | hard | {
"lang": "rust",
"repo": "Azure/iotedge",
"path": "/edgelet/iotedge/src/check/checks/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chaosprint/glicol path: /rs/synth/examples/chain.rs
use glicol_synth::{
AudioContextBuilder,
oscillator::SinOsc,
operator::Mul,
signal::ConstSig,
Message
};
fn main() {
<|fim_suffix|> let node_a = context.add_mono_node(ConstSig::new(24.));
let node_b = context.add_mon... | code_fim | medium | {
"lang": "rust",
"repo": "chaosprint/glicol",
"path": "/rs/synth/examples/chain.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> context.chain(vec![node_a, node_b, context.destination]);
println!("first block {:?}", context.next_block());
}<|fim_prefix|>// repo: chaosprint/glicol path: /rs/synth/examples/chain.rs
use glicol_synth::{
AudioContextBuilder,
oscillator::SinOsc,
operator::Mul,
signal::ConstSig,
... | code_fim | medium | {
"lang": "rust",
"repo": "chaosprint/glicol",
"path": "/rs/synth/examples/chain.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: azdavis/advent-of-code path: /years/y2015/src/d11.rs
use helpers::HashSet;
fn valid(s: &[u8]) -> bool {
if !s.windows(3).any(|w| w[0] + 1 == w[1] && w[1] + 1 == w[2]) {
return false;
}
if s.iter().any(|&c| matches!(c, b'i' | b'o' | b'l')) {
return false;
}
let two_same: HashSe... | code_fim | hard | {
"lang": "rust",
"repo": "azdavis/advent-of-code",
"path": "/years/y2015/src/d11.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let s = include_str!("input/d11.txt");
assert_eq!(p1(s), "hepxxyzz");
assert_eq!(p2(s), "heqaabcc");
}<|fim_prefix|>// repo: azdavis/advent-of-code path: /years/y2015/src/d11.rs
use helpers::HashSet;
fn valid(s: &[u8]) -> bool {
if !s.windows(3).any(|w| w[0] + 1 == w[1] && w[1] + 1 == w[2]) {
... | code_fim | medium | {
"lang": "rust",
"repo": "azdavis/advent-of-code",
"path": "/years/y2015/src/d11.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn penalty_remove_total() {
// total should return the sume of the base score and the enhancement bonus
let base: Option<u8> = Some(10);
let mut score = ability_scores::GenericAbilityScore::new(base);
score.add_penalty(2);
score.remove_penalty(2);
... | code_fim | hard | {
"lang": "rust",
"repo": "mediocresurgeon/rust-char-gen",
"path": "/src/ability_scores/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.untyped_bonus.remove(bonus);
return self;
}
fn get_untyped(&mut self) -> u8 {
return self.untyped_bonus.total();
}
}
#[cfg(test)]
mod genericabilityscoretests {
use super::*;
use ability_scores;
#[test]
fn default_get_base() {
// the ... | code_fim | hard | {
"lang": "rust",
"repo": "mediocresurgeon/rust-char-gen",
"path": "/src/ability_scores/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mediocresurgeon/rust-char-gen path: /src/ability_scores/mod.rs
use bonuses;
use bonuses::BonusTracker;
pub use self::charisma::{ Charisma };
pub use self::constitution::{ Constitution };
pub use self::dexterity::{ Dexterity };
pub use self::intelligence::{ Intelligence };
pub use self::strength:... | code_fim | hard | {
"lang": "rust",
"repo": "mediocresurgeon/rust-char-gen",
"path": "/src/ability_scores/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Padding for PaddingOaes {
fn pad_block(block: &mut [u8], pos: usize) -> Result<(), PadError> {
if pos >= block.len() {
return Err(PadError);
}
block
.iter_mut()
.skip(pos)
.enumerate()
.for_each(|(idx, byte)| {
... | code_fim | hard | {
"lang": "rust",
"repo": "moschroe/roaes",
"path": "/src/util/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: moschroe/roaes path: /src/util/mod.rs
use crate::RoaesError;
use aes::{Aes128, Aes192, Aes256, NewBlockCipher};
use bitflags::bitflags;
use block_modes::block_padding::{PadError, Padding, UnpadError};
use std::cmp::min;
#[derive(Clone)]
pub(crate) enum Aess {
Aes128(Aes128),
Aes192(Aes1... | code_fim | hard | {
"lang": "rust",
"repo": "moschroe/roaes",
"path": "/src/util/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if pos >= block.len() {
return Err(PadError);
}
block
.iter_mut()
.skip(pos)
.enumerate()
.for_each(|(idx, byte)| {
*byte = (idx + 1) as u8;
});
Ok(())
}
fn unpad(data: &[u8]) -... | code_fim | hard | {
"lang": "rust",
"repo": "moschroe/roaes",
"path": "/src/util/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: throwaway1940/exchange path: /exchange/src/exchange.rs
use std::collections::HashMap;
use crate::{
Client, ClientID, ExchangeError, Registry, Transaction, TransactionID, TransactionType,
};
/// An exchange keeps track of all transactions.
/// It is designed to always be in a valid state.
/... | code_fim | hard | {
"lang": "rust",
"repo": "throwaway1940/exchange",
"path": "/exchange/src/exchange.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for Exchange {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)]
mod test_exchange {
use crate::Amount;
use super::*;
#[test]
fn test_deposit() {
let mut exchange = Exchange::new();
let tx = Transaction::new(1, 1, TransactionType::Deposit(A... | code_fim | hard | {
"lang": "rust",
"repo": "throwaway1940/exchange",
"path": "/exchange/src/exchange.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> DerefMut for Env<T> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.entries
}
}<|fim_prefix|>// repo: nixpulvis/tiger path: /src/env.rs
use std::ops::{Deref, DerefMut};
use std::collections::HashMap;
use syntax::ast::Symbol;
use ty::Type;
#[derive(Clone, PartialEq, Eq,... | code_fim | medium | {
"lang": "rust",
"repo": "nixpulvis/tiger",
"path": "/src/env.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for Env<Value> {
fn default() -> Self {
Env {
entries: HashMap::new(),
}
}
}
impl<T> Deref for Env<T> {
type Target = HashMap<Symbol, T>;
fn deref(&self) -> &Self::Target {
&self.entries
}
}
impl<T> DerefMut for Env<T> {
fn deref_... | code_fim | hard | {
"lang": "rust",
"repo": "nixpulvis/tiger",
"path": "/src/env.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nixpulvis/tiger path: /src/env.rs
use std::ops::{Deref, DerefMut};
use std::collections::HashMap;
use syntax::ast::Symbol;
use ty::Type;
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct Env<T> {
entries: HashMap<Symbol, T>,
}
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum Value {
Var... | code_fim | medium | {
"lang": "rust",
"repo": "nixpulvis/tiger",
"path": "/src/env.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ilaborie/rust-montecarlo path: /src/lib.rs
#[derive(Debug)]
pub struct Point {
x: f64,
y: f64,
}
impl Point {
pub fn new(x: f64, y: f64) -> Point {
Point { x, y }
}
<|fim_suffix|>pub fn loop_for<S>(count: i32, mut func: S) -> (f64, S) where S: FnMut() -> Point {
let... | code_fim | medium | {
"lang": "rust",
"repo": "ilaborie/rust-montecarlo",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn loop_for<S>(count: i32, mut func: S) -> (f64, S) where S: FnMut() -> Point {
let mut in_circle = 0;
for _i in 0..count {
let p = func();
in_circle += if p.is_in_circle() { 1 } else { 0 }
}
let pi = compute(in_circle as f64, count as f64);
(pi, func)
}
pub fn lo... | code_fim | medium | {
"lang": "rust",
"repo": "ilaborie/rust-montecarlo",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn loop_for<S>(count: i32, mut func: S) -> (f64, S) where S: FnMut() -> Point {
let mut in_circle = 0;
for _i in 0..count {
let p = func();
in_circle += if p.is_in_circle() { 1 } else { 0 }
}
let pi = compute(in_circle as f64, count as f64);
(pi, func)
}
pub fn l... | code_fim | medium | {
"lang": "rust",
"repo": "ilaborie/rust-montecarlo",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn load(path: &Path) -> Option<UseFile> {
fs::read_to_string(path)
.ok()
.map(|contents| toml::from_str(&contents).unwrap())
}
pub fn save(use_def: &UseFile, path: &Path) -> Result<(), io::Error> {
let toml = toml::to_string_pretty(use_def).expect("failed to serialize use toml... | code_fim | medium | {
"lang": "rust",
"repo": "dotboris/alt",
"path": "/src/use_file.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dotboris/alt path: /src/use_file.rs
use std::collections::HashMap;
use std::fs;
use std::io;
use std::path::{Path, PathBuf};
const FILE_NAME: &str = ".alt.toml";
pub fn find(start: &Path) -> Option<PathBuf> {
let mut dir = PathBuf::from(start);
loop {
let file = dir.join(FILE_N... | code_fim | medium | {
"lang": "rust",
"repo": "dotboris/alt",
"path": "/src/use_file.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn find_or_dir(start: &Path) -> PathBuf {
find(start).unwrap_or_else(|| start.join(FILE_NAME))
}
pub type UseFile = HashMap<String, String>;
pub fn load(path: &Path) -> Option<UseFile> {
fs::read_to_string(path)
.ok()
.map(|contents| toml::from_str(&contents).unwrap())
}
pub... | code_fim | hard | {
"lang": "rust",
"repo": "dotboris/alt",
"path": "/src/use_file.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anderslanglands/usd-bind path: /usd-rs/crates/usd-sdf/src/path.rs
use std::ffi::CStr;
use usd_sys as sys;
use usd_cppstd::CppString;
use cppmm_refptr::{OpaquePtr, Ref, RefMut};
#[repr(transparent)]
pub struct SdfPath(pub *mut sys::pxr_SdfPath_t);
unsafe impl OpaquePtr for SdfPath {
type Sy... | code_fim | hard | {
"lang": "rust",
"repo": "anderslanglands/usd-bind",
"path": "/usd-rs/crates/usd-sdf/src/path.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn from_slice(s: &[SdfPath]) -> Self {
let mut vec = Self::new();
vec.reserve(s.len());
for p in s {
unsafe {
let mut tmp = std::ptr::null_mut();
// FIXME: don't want to be doing two copies here but can't
// get t... | code_fim | hard | {
"lang": "rust",
"repo": "anderslanglands/usd-bind",
"path": "/usd-rs/crates/usd-sdf/src/path.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // check the result
let json_data = util::read_file("tests/integration/json/query_message.json")?;
let result = ch_api.query_with_pid(&TOKEN.to_string(), &pid, json_data.clone())?;
let payload_messages: Vec<IdsMessage> = serde_json::from_str(result.payload.as_ref().unwrap())?;
assert_e... | code_fim | hard | {
"lang": "rust",
"repo": "IDSCN/ids-clearing-house-service",
"path": "/clearing-house-app/clearing-house-api/tests/integration/test_log_message.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // prepare test data
let dt_id = DOC_TYPE.to_string();
let pid = String::from("test_log_message_to_existing_pid");
// clean up doc type (in case of previous test failure)
delete_test_doc_type_from_keyring(&TOKEN.to_string(), &pid, &dt_id)?;
insert_test_doc_type_into_keyring(&TOKEN... | code_fim | hard | {
"lang": "rust",
"repo": "IDSCN/ids-clearing-house-service",
"path": "/clearing-house-app/clearing-house-api/tests/integration/test_log_message.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (i, n) in i_map {
if a_map.values().all(|s| !s.contains(i)) {
part1 += n;
}
}
println!("Part 1: {}", part1);
let mut dil: Vec<(String, String)> = vec![];
while let Some(k) = a_map.keys().cloned().find(|k| a_map[k].len() == 1) {
let val = a_map... | code_fim | hard | {
"lang": "rust",
"repo": "alexarice/aoc2020",
"path": "/day21/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexarice/aoc2020 path: /day21/main.rs
use regex::Regex;
use std::collections::{HashMap, HashSet};
use std::fs;
fn main() {
let input = fs::read_to_string("input.txt").expect("Something went wrong reading the file");
let lines = input.lines();
let re = Regex::new(r"(.*) \(contains... | code_fim | medium | {
"lang": "rust",
"repo": "alexarice/aoc2020",
"path": "/day21/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pawroman/torchbear path: /src/bindings/web/client.rs
use actix_web::{
http::Method,
HttpMessage,
client::{ClientRequest, ClientRequestBuilder, ClientResponse}
};
use futures::Future;
use rlua::prelude::*;
use rlua_serde;
use serde_json::{self, Value as JsonValue};
use std::str::FromS... | code_fim | hard | {
"lang": "rust",
"repo": "pawroman/torchbear",
"path": "/src/bindings/web/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
fn send_lua_request <'a> (lua: LuaContext<'a>, val: LuaValue<'a>) -> Result<LuaTable<'a>, LuaError> {
let mut builder = ClientRequest::build();
let body = match val {
LuaValue::String(s) => {
builder.uri(s.to_str()?).method(Method::GET);
None
... | code_fim | hard | {
"lang": "rust",
"repo": "pawroman/torchbear",
"path": "/src/bindings/web/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(headers) = table.get("headers")? {
set_headers(headers, &mut builder)?;
}
table.get("body")?
},
_ => {
return Err(LuaError::RuntimeError("Invalid arguments".to_string()))
}
};
let response = (matc... | code_fim | hard | {
"lang": "rust",
"repo": "pawroman/torchbear",
"path": "/src/bindings/web/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> msg!("Calling the token program to transfer tokens to the escrow's initializer...");
// use signature extension to make the token transfer to Alice's Y token account on Bob's behalf.
invoke(
&transfer_to_initializer_ix,
&[
taker_y_acc.clone(... | code_fim | hard | {
"lang": "rust",
"repo": "crypto-forks/solana-simple-escrow",
"path": "/rs/src/processor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: crypto-forks/solana-simple-escrow path: /rs/src/processor.rs
(accounts, amount, program_id)
}
EscrowInstruction::Exchange { amount } => {
msg!("Instruction: Exchange");
Self::process_exchange(accounts, amount, program_id)
}
... | code_fim | hard | {
"lang": "rust",
"repo": "crypto-forks/solana-simple-escrow",
"path": "/rs/src/processor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // note we're using invoke_signed here because we're signing with a pda
// because the pda doesn't actually have a private key associatd with it (its off the curve)
// we instead pass its seed, which is used as proof
// no other program can fake this PDA because it requires... | code_fim | hard | {
"lang": "rust",
"repo": "crypto-forks/solana-simple-escrow",
"path": "/rs/src/processor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn determine_params<I>(args: I) -> Option<(Vec<String>, WriteMode)>
where I: Iterator<Item = String>
{
let arg_prefix = "-";
let write_mode_prefix = "--write-mode=";
let help_mode = "-h";
let long_help_mode = "--help";
let mut write_mode = WriteMode::Replace;
let mut rustc_args... | code_fim | hard | {
"lang": "rust",
"repo": "iwillspeak/rustfmt",
"path": "/src/bin/rustfmt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iwillspeak/rustfmt path: /src/bin/rustfmt.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.ap... | code_fim | hard | {
"lang": "rust",
"repo": "iwillspeak/rustfmt",
"path": "/src/bin/rustfmt.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let config = match lookup_and_read_project_file() {
Ok((path, toml)) => {
println!("Project config file: {}", path.display());
Config::from_toml(&toml)
}
Err(_) => Default::default(),
};
run(args, write_mode, &config);
0
}
fn main() {
u... | code_fim | hard | {
"lang": "rust",
"repo": "iwillspeak/rustfmt",
"path": "/src/bin/rustfmt.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn main() {
assert!(compare("foo", "foo"));
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-3574.rs
// run-pass
// rustc --test match_borrowed_str.rs.rs && ./match_borrowed_str.rs
<|fim_middle|>
fn compare(x: &str, y: &str) -> bool {
match x {
... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/issues/issue-3574.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-3574.rs
// run-pass
// rustc --test match_borrowed_str.rs.rs && ./match_borrowed_str.rs
fn compare(x: &str, y: &str) -> bool {
<|fim_suffix|>pub fn main() {
assert!(compare("foo", "foo"));
}<|fim_middle|> match x {
... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/issues/issue-3574.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: willcrichton/rapier path: /src/dynamics/solver/position_ground_constraint_wide.rs
use super::AnyPositionConstraint;
use crate::dynamics::{IntegrationParameters, RigidBodySet};
use crate::geometry::{ContactManifold, KinematicsCategory};
use crate::math::{
AngularInertia, Isometry, Point, Rota... | code_fim | hard | {
"lang": "rust",
"repo": "willcrichton/rapier",
"path": "/src/dynamics/solver/position_ground_constraint_wide.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let radius = radius1 + radius2 /*- SimdFloat::splat(params.allowed_linear_error)*/;
let n1 = coll_pos1 * local_n1;
for l in (0..manifolds[0].num_active_contacts()).step_by(MAX_MANIFOLD_POINTS) {
let manifold_points = array![|ii| &manifolds[ii].active_contacts()[l..]; ... | code_fim | hard | {
"lang": "rust",
"repo": "willcrichton/rapier",
"path": "/src/dynamics/solver/position_ground_constraint_wide.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn solve_plane_point(
&self,
params: &IntegrationParameters,
positions: &mut [Isometry<f32>],
) {
// FIXME: can we avoid most of the multiplications by pos1/pos2?
// Compute jacobians.
let mut pos2 = Isometry::from(array![|ii| positions[self.rb2[... | code_fim | hard | {
"lang": "rust",
"repo": "willcrichton/rapier",
"path": "/src/dynamics/solver/position_ground_constraint_wide.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bmatcuk/adventofcode2019 path: /day11/src/bin/part2.rs
//! --- Part Two ---
//!
//! You're not sure what it's trying to paint, but it's definitely not a registration identifier.
//! The Space Police are getting impatient.
//!
//! Checking your external ship cameras again, you notice a white pane... | code_fim | hard | {
"lang": "rust",
"repo": "bmatcuk/adventofcode2019",
"path": "/day11/src/bin/part2.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Eq, Hash, PartialEq)]
struct HullPanel {
x: isize,
y: isize,
}
impl HullPanel {
fn new(x: isize, y: isize) -> HullPanel {
HullPanel { x, y }
}
}
enum Direction {
Down,
Left,
Right,
Up,
}
impl Direction {
fn turn(self, how: i64) -> Direction {
... | code_fim | hard | {
"lang": "rust",
"repo": "bmatcuk/adventofcode2019",
"path": "/day11/src/bin/part2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut test = vec![
30, 63, 83, 40, 15, 45, 46, 15, 56, 39, 82, 97, 59, 88, 3, 1, 40, 95, 83, 32, 38, 70, 4,
87, 54, 48, 19, 8, 52, 49, 64, 72, 46, 72, 59, 36, 21, 68, 81, 34, 23, 6, 70, 80, 80, 12,
32, 84, 17, 19, 28, 58, 68, 19, 65, 46, 43, 22, 12, 95, 89, 15, 39, 88, 64, 95... | code_fim | hard | {
"lang": "rust",
"repo": "ccqpein/Arithmetic-Exercises",
"path": "/Bubble-Sort/BS.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ccqpein/Arithmetic-Exercises path: /Bubble-Sort/BS.rs
use std::fmt::Debug;
fn bubble_sort<T>(a: &Vec<T>) -> Vec<T>
where
T: PartialEq + PartialOrd + Clone,
{
let length = a.len();
let mut flag = true;
let mut b = a.clone();
while (flag) {
flag = false;
let mu... | code_fim | hard | {
"lang": "rust",
"repo": "ccqpein/Arithmetic-Exercises",
"path": "/Bubble-Sort/BS.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>where
T: PartialEq + PartialOrd + Clone + Debug,
{
let length = a.len();
if length == 0 {
return Vec::new();
}
let mut flag = true;
let mut aa = a.clone();
while flag {
flag = false;
let mut this = aa[0].clone();
let mut temp_vec: Vec<T> = vec![]... | code_fim | hard | {
"lang": "rust",
"repo": "ccqpein/Arithmetic-Exercises",
"path": "/Bubble-Sort/BS.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
self.processor.write(headers, data);
}
);
let fn_flush: TokenStream = quote!(
fn flush(&mut self, headers: &Headers) -> ()
{
self.processor.flush(headers);
let processor = &self.processor;
... | code_fim | hard | {
"lang": "rust",
"repo": "Gnitive/multipart",
"path": "/derive/src/multipart_field.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Gnitive/multipart path: /derive/src/multipart_field.rs
use proc_macro2::{Ident, Span, TokenStream};
use quote::{ToTokens};
use syn::{Attribute, Expr, Field, Path, PathArguments, Type};
use attributes_utils::{get_string, get_bool, get_usize, ident_to_string, collect_attribute};
/// Wrapper for ... | code_fim | hard | {
"lang": "rust",
"repo": "Gnitive/multipart",
"path": "/derive/src/multipart_field.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let fn_open: TokenStream = quote!(
fn open(&mut self, headers: &Headers) -> ()
{
self.processor.open(headers);
}
);
let fn_write: TokenStream = quote!(
fn write(&mut self, headers: &Headers, data: &Vec<u8>) -> ()
... | code_fim | hard | {
"lang": "rust",
"repo": "Gnitive/multipart",
"path": "/derive/src/multipart_field.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bethebunny/conflag path: /src/builtins.rs
use core::fmt;
use std::{
collections::HashMap,
fs,
path::{Path, PathBuf},
rc::Rc,
};
use crate::{ast::AstNode, scope::ScopePtr, thunk::Thunk, value::Value, Error, Result};
// TODO:
// - rewrite builtins using from_N interface
// - sign... | code_fim | hard | {
"lang": "rust",
"repo": "bethebunny/conflag",
"path": "/src/builtins.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
P: AsRef<Path>,
{
let path = path.as_ref();
let lib = crate::stdlib::modules();
if let Some(module) = path.to_str().and_then(|p| lib.get(p)) {
return Ok(module.clone());
}
for dir in [&self.dir, &self.base_dir] {
let pat... | code_fim | hard | {
"lang": "rust",
"repo": "bethebunny/conflag",
"path": "/src/builtins.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn builtin_reduce(args: &[Thunk]) -> Result<Thunk> {
if let [f, array, state] = args {
match &*array.evaluate()? {
Value::Array(values) => {
let mut state = state.clone();
for v in values.iter() {
state = Value::FunctionCall {
... | code_fim | hard | {
"lang": "rust",
"repo": "bethebunny/conflag",
"path": "/src/builtins.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jgjin/queue-service path: /src/other_services.rs
use std::{
sync::{
Arc,
},
};
use crossbeam_queue::{
SegQueue,
};
use grpcio::{
ChannelBuilder,
EnvBuilder,
};
use crate::{
email::{
EmailRequest,
EmailResponse,
},
email_grpc::{
Em... | code_fim | medium | {
"lang": "rust",
"repo": "jgjin/queue-service",
"path": "/src/other_services.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> addr: String,
body: String,
client: &EmailServiceClient,
) -> grpcio::Result<()> {
let mut req = EmailRequest::new();
req.set_to(addr);
req.set_subject("Laundry Update".to_string());
req.set_body(body);
client.send_email(&req).map(|_| {
// TODO: handle?
()
... | code_fim | medium | {
"lang": "rust",
"repo": "jgjin/queue-service",
"path": "/src/other_services.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
x,
Ipsum {
foo: 42u32,
strip_opt: Some("bar".to_string()),
strip_opt_with_default: None,
}
);
}<|fim_prefix|>// repo: colin-kiegel/rust-derive-builder path: /derive_builder/tests/setter_strip_option.rs
#[macro_use]
extern cra... | code_fim | medium | {
"lang": "rust",
"repo": "colin-kiegel/rust-derive-builder",
"path": "/derive_builder/tests/setter_strip_option.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: colin-kiegel/rust-derive-builder path: /derive_builder/tests/setter_strip_option.rs
#[macro_use]
extern crate pretty_assertions;
#[macro_use]
extern crate derive_builder;
#[derive(Debug, PartialEq, Default, Builder, Clone)]
struct Lorem {
#[builder(setter(into))]
full_opt: Option<String... | code_fim | medium | {
"lang": "rust",
"repo": "colin-kiegel/rust-derive-builder",
"path": "/derive_builder/tests/setter_strip_option.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.