text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: willstott101/if-addrs path: /src/windows.rs
// Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
// https://opensource.org/licenses/BSD-3-Clau... | code_fim | hard | {
"lang": "rust",
"repo": "willstott101/if-addrs",
"path": "/src/windows.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: djdisodo/pi_calculator path: /untitled/src/main.rs
use std::f64::consts::PI;
use std::ops::{Range, Deref};
use std::time::{Instant, Duration};
use cairo::Context;
use gtk::{Inhibit, ContainerExt, WidgetExt, BoxExt, Button, LabelExt};
use gtk::prelude::{BuilderExtManual, WidgetExtManual};
use std... | code_fim | hard | {
"lang": "rust",
"repo": "djdisodo/pi_calculator",
"path": "/untitled/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> drawing_area.set_size_request(500, 500);
drawing_area.connect_draw(move |da, context| {
draw(context, chunks);
Inhibit(true)
});
let r = &main_box.get_children()[0];
main_box.remove(r);
main_box.add(&drawing_area);
main_box.set_child_position(&drawing_area, 0);
... | code_fim | hard | {
"lang": "rust",
"repo": "djdisodo/pi_calculator",
"path": "/untitled/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zthompson47/tokio-uring path: /src/driver/util.rs
use std::ffi::CString;
use std::io;
use std::path::Path;
/*
/// Prepare a SQE
pub(super) fn push_sqe(uring: &mut IoUring, &squeue::Entry) -> io::Result<()> {
if uring.sq_space_left() == 0 {
uring.submit_sqes()?;
}
Ok(uring.p... | code_fim | medium | {
"lang": "rust",
"repo": "zthompson47/tokio-uring",
"path": "/src/driver/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// pub(crate) fn set(&mut self, cx: &mut Context<'_>) {
// match &mut self.0 {
// // Waker is already stored
// Some(w) if w.will_wake(cx.waker()) => {}
// // Waker needs to be stored
// waker => *waker = Some(cx.waker().clone()),
// }
//... | code_fim | hard | {
"lang": "rust",
"repo": "zthompson47/tokio-uring",
"path": "/src/driver/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// #[derive(Default)]
// pub(crate) struct MaybeWaker(Option<Waker>);
// impl MaybeWaker {
// pub(crate) fn new(waker: Waker) -> MaybeWaker {
// MaybeWaker(Some(waker))
// }
// pub(crate) fn set(&mut self, cx: &mut Context<'_>) {
// match &mut self.0 {
// // Waker... | code_fim | hard | {
"lang": "rust",
"repo": "zthompson47/tokio-uring",
"path": "/src/driver/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PFC-Validator/constellation-observer path: /src/b64.rs
/// Convert a f64 number (which is sent as a string) into a f64 rust structure
pub mod b64_format {
use serde::{self, Deserialize, Deserializer, Serializer};
// convert a number in string format into a regular u64
//
// f... | code_fim | hard | {
"lang": "rust",
"repo": "PFC-Validator/constellation-observer",
"path": "/src/b64.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RUB-SysSec/nautilus path: /gramophone/src/generator.rs
extern crate antlr_parser;
#[macro_use]
extern crate clap;
extern crate grammartec;
extern crate ron;
extern crate serde_json;
use grammartec::context::Context;
use grammartec::context::SerializableContext;
use grammartec::newtypes::NTermID... | code_fim | hard | {
"lang": "rust",
"repo": "RUB-SysSec/nautilus",
"path": "/gramophone/src/generator.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> //Generate Tree
if store {
if Path::new("corpus").exists() {
} else {
fs::create_dir("corpus").expect("Could not create corpus directory");
}
}
for i in 0..number_of_trees {
let nonterm = NTermID::from(1);
let len = ctx.get_random_len_for... | code_fim | hard | {
"lang": "rust",
"repo": "RUB-SysSec/nautilus",
"path": "/gramophone/src/generator.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Deref for CentralHarness {
type Target = Expectable<CentralState, Aux>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for CentralHarness {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl TestHarness for CentralHarness {
typ... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/bluetooth/testing/bt-test-harness/src/low_energy_central.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/connectivity/bluetooth/testing/bt-test-harness/src/low_energy_central.rs
// Copyright 2022 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 {
anyhow::{Context as ... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/connectivity/bluetooth/testing/bt-test-harness/src/low_energy_central.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for t in tests {
let ctx = crate::tests::try_create_context()?;
let plan = PlanParser::create(ctx.clone()).build_from_sql(t.query)?;
let mut optimizer = AliasPushDownOptimizer::create(ctx);
let optimized = optimizer.optimize(&plan)?;
let actual = format!("{:?}... | code_fim | hard | {
"lang": "rust",
"repo": "r-asou/databend",
"path": "/query/src/optimizers/optimizer_alias_push_down_test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: r-asou/databend path: /query/src/optimizers/optimizer_alias_push_down_test.rs
// Copyright 2020 Datafuse Labs.
//
// 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
// ... | code_fim | hard | {
"lang": "rust",
"repo": "r-asou/databend",
"path": "/query/src/optimizers/optimizer_alias_push_down_test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> use crate::optimizers::*;
use crate::sql::*;
#[allow(dead_code)]
struct Test {
name: &'static str,
query: &'static str,
expect: &'static str,
}
let tests = vec![
Test {
name:"filter-alias-push-down",
query: "select (number+1... | code_fim | hard | {
"lang": "rust",
"repo": "r-asou/databend",
"path": "/query/src/optimizers/optimizer_alias_push_down_test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Can be implemented for the receiving side of a socket.
pub trait PacketReceiving {
/// Start receiving data.
/// You have to pass the `Sender` side of a channel to this function so that the `Receiver` side of the channel can read all received packets send on this `Sender` by this function.
... | code_fim | medium | {
"lang": "rust",
"repo": "kabergstrom/amethyst",
"path": "/amethyst_network/src/server/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
/// Can be implemented for the sending side of a socket.
pub trait PacketSending {
/// This will send all data.
/// You have to pass the `Receiver` side of a channel to this function so that packets send on the `Sender` could be read by this function.
fn start_sending(&mut self, rx: Receive... | code_fim | hard | {
"lang": "rust",
"repo": "kabergstrom/amethyst",
"path": "/amethyst_network/src/server/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kabergstrom/amethyst path: /amethyst_network/src/server/mod.rs
mod config;
mod host;
mod receive_handler;
mod send_handler;
mod server_socket_event;
mod udp;
pub use self::{
config::ServerConfig,
host::Host,
receive_handler::ReceiveHandler,
send_handler::SendHandler,
udp::{U... | code_fim | medium | {
"lang": "rust",
"repo": "kabergstrom/amethyst",
"path": "/amethyst_network/src/server/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Decorator, procedural macro. Grab all the code below and plug it into a tokyo times.
#[actix_web::main]
async fn main() -> std::io::Result<()> {
// To use environment variables
dotenv::dotenv().ok();
let port = std::env::var("PORT").unwrap_or("4001".to_string());
let address = format!("... | code_fim | hard | {
"lang": "rust",
"repo": "HenryLeon95/apiRust",
"path": "/src/example1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HenryLeon95/apiRust path: /src/example1.rs
#![allow(non_snake_case)]
extern crate dotenv;
//use actix_web -> Import a series of elementor
//use std::sync::atomic::{AtomicU16, Ordering};
//use std::sync::Arc;
use actix_web::{web, App, HttpServer, Responder};
/*
let tweet = models::Tweet {
n... | code_fim | hard | {
"lang": "rust",
"repo": "HenryLeon95/apiRust",
"path": "/src/example1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Entry point
// Returns a Result of type IO.
// If everything goes well it returns a unit type. If there is an error, it returns an IO type.
// All the code with the decorator is equal to:
// fn main() -> std::io::Result<()> {
// actix_web::rt::System::new("main").block_on(
// async {
// ... | code_fim | hard | {
"lang": "rust",
"repo": "HenryLeon95/apiRust",
"path": "/src/example1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arpan-dhatt/roomie path: /src/eid.rs
use crate::model::BackendEIDFormData;
use actix_web::{client::Client, web::Buf, HttpMessage};
use regex::Regex;
pub async fn check_eid(eid: &str) -> Result<bool, &'static str> {
let client = Client::default();
let mut response = client.get("https://i... | code_fim | hard | {
"lang": "rust",
"repo": "arpan-dhatt/roomie",
"path": "/src/eid.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn check_final_page(body: &str) -> bool {
(body.contains("Page ID: RP8") || body.contains("Page ID: RP3")) && !body.contains("valid")
}
#[actix_rt::test]
async fn test_eid_checker() {
use dotenv::dotenv;
dotenv().ok();
let valid_eid = std::env::var("TEST_VALID_EID").unwrap();
assert_e... | code_fim | hard | {
"lang": "rust",
"repo": "arpan-dhatt/roomie",
"path": "/src/eid.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> message: String,
from: UserRef,
}<|fim_prefix|>// repo: FlatBartender/mindmap path: /src/models/comment.rs
use crate::models::{
mind_map::Node<|fim_middle|>Ref,
UserRef,
};
#[derive(Clone)]
pub struct Comment {
node: NodeRef,
| code_fim | medium | {
"lang": "rust",
"repo": "FlatBartender/mindmap",
"path": "/src/models/comment.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FlatBartender/mindmap path: /src/models/comment.rs
use crate::models::{
mind_map::NodeRef,
UserRef,
};
#[derive(Clone)]
p<|fim_suffix|> message: String,
from: UserRef,
}<|fim_middle|>ub struct Comment {
node: NodeRef,
| code_fim | easy | {
"lang": "rust",
"repo": "FlatBartender/mindmap",
"path": "/src/models/comment.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jackcook/beam-client-rust path: /src/routes/teams.rs
extern crate rustc_serialize;
use rustc_serialize::json;
use ::request::{BeamRequest, HttpMethod};
use error::Error;
use ::models::team::BeamTeam;
use ::models::user::BeamUser;
/// Result from a call returning a stream team.
pub type BeamTe... | code_fim | hard | {
"lang": "rust",
"repo": "jackcook/beam-client-rust",
"path": "/src/routes/teams.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return Ok(decoded);
},
Err(_) => return Err(Error::Json)
}
}
/// Retrieves all stream teams, paginated and descending by viewer count.
///
/// # Arguments
///
/// * `page` The page of teams to retrieve.
///
/// # Example
... | code_fim | hard | {
"lang": "rust",
"repo": "jackcook/beam-client-rust",
"path": "/src/routes/teams.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MarcusTL12/AdventOfCode2015Rust path: /src/day9.rs
use std::{
collections::{HashMap, HashSet},
fs::File,
io::{BufRead, BufReader},
iter,
};
use itertools::Itertools;
use regex::Regex;
use lazy_static::*;
pub const PARTS: [fn(); 2] = [part1, part2];
lazy_static! {
static ... | code_fim | hard | {
"lang": "rust",
"repo": "MarcusTL12/AdventOfCode2015Rust",
"path": "/src/day9.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (dists, places) = parse_input("inputfiles/day9/input.txt");
//
let ans = places
.iter()
.permutations(places.len())
.map(|p| {
p.iter()
.tuple_windows()
.map(|(&d1, &d2)| dists[&(d1.clone(), d2.clone())])
.... | code_fim | hard | {
"lang": "rust",
"repo": "MarcusTL12/AdventOfCode2015Rust",
"path": "/src/day9.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ("eval", Some(matches)) => {
let obf = matches.value_of("obf_file").unwrap();
let inp = matches.value_of("INPUT").expect("INPUT required!");
eval_main(obf, inp);
}
_ => {}
}
}
fn obf_main(pat_inp: &str, output_file: &str, secparam: usize) {
... | code_fim | hard | {
"lang": "rust",
"repo": "spaceships/wildcard-obfuscation",
"path": "/app/wildcard.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut pat;
if pat_inp == "-" {
pat = String::new();
let stdin = std::io::stdin();
let mut handle = stdin.lock();
handle.read_to_string(&mut pat).unwrap();
} else {
pat = pat_inp.to_string();
}
for c in pat.chars() {
match c {
... | code_fim | hard | {
"lang": "rust",
"repo": "spaceships/wildcard-obfuscation",
"path": "/app/wildcard.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spaceships/wildcard-obfuscation path: /app/wildcard.rs
extern crate clap;
extern crate wildcard;
use wildcard::protocol::Obf;
use std::io::Read;
use clap::{Arg, App, SubCommand, AppSettings};
use std::process::exit;
fn main() {
let matches = App::new("wildcard")
.setting(AppSettin... | code_fim | hard | {
"lang": "rust",
"repo": "spaceships/wildcard-obfuscation",
"path": "/app/wildcard.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: segeljakt/derive_less path: /examples/fn.rs
#![allow(dead_code)]
#![allow(unused_attributes)]
<|fim_suffix|>derive_less! {
pub fn __() {}
fn foo() {
}
}
fn main() {}<|fim_middle|>use derive_less::derive_less;
| code_fim | easy | {
"lang": "rust",
"repo": "segeljakt/derive_less",
"path": "/examples/fn.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>derive_less! {
pub fn __() {}
fn foo() {
}
}
fn main() {}<|fim_prefix|>// repo: segeljakt/derive_less path: /examples/fn.rs
#![allow(dead_code)]
#![allow(unused_attributes)]
<|fim_middle|>use derive_less::derive_less;
| code_fim | easy | {
"lang": "rust",
"repo": "segeljakt/derive_less",
"path": "/examples/fn.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
}
fn main() {}<|fim_prefix|>// repo: segeljakt/derive_less path: /examples/fn.rs
#![allow(dead_code)]
#![allow(unused_attributes)]
use derive_less::derive_less;
derive_less! {
<|fim_middle|> pub fn __() {}
fn foo() {
| code_fim | easy | {
"lang": "rust",
"repo": "segeljakt/derive_less",
"path": "/examples/fn.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if SpanlessEq::new(cx).eq_expr(arg1, arg2) {
span_lint(cx, NO_EFFECT_REPLACE, expr.span, "replacing text with itself");
}
}
fn lit_string_value(node: &LitKind) -> Option<String> {
match node {
LitKind::Char(value) => Some(value.to_string()),
LitKind::Str(value, _) => S... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/src/tools/clippy/clippy_lints/src/methods/no_effect_replace.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /src/tools/clippy/clippy_lints/src/methods/no_effect_replace.rs
use clippy_utils::diagnostics::span_lint;
use clippy_utils::ty::is_type_lang_item;
use clippy_utils::SpanlessEq;
use if_chain::if_chain;
use rustc_ast::LitKind;
use rustc_hir::{ExprKind, LangItem};
use rustc_lin... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/src/tools/clippy/clippy_lints/src/methods/no_effect_replace.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 10allday-kai/api-daemon path: /third-party/slice-deque/benches/insert.rs
#![feature(test)]
#![cfg_attr(feature = "cargo-clippy", allow(option_unwrap_used))]
extern crate slice_deque;
extern crate test;
use std::collections::VecDeque;
const MAX_NO_ITERS: usize = 1_000_000_000;
#[bench]
fn ins... | code_fim | hard | {
"lang": "rust",
"repo": "10allday-kai/api-daemon",
"path": "/third-party/slice-deque/benches/insert.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[bench]
fn insert_three_quarter_vdeq(b: &mut test::Bencher) {
let mut deq = VecDeque::<u8>::with_capacity(MAX_NO_ITERS);
deq.resize(10, 3);
b.iter(|| {
let i = (deq.len() - 1) / 4 * 3;
test::black_box(deq.insert(i, 3));
test::black_box(&mut deq);
});
}
#[bench]
fn... | code_fim | hard | {
"lang": "rust",
"repo": "10allday-kai/api-daemon",
"path": "/third-party/slice-deque/benches/insert.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn new_v_data(&self, len: i32) -> Result<DatAddr, Error> {
let result = unsafe {
NewVData(self.0, len)
};
if result == 0 || result > (i32::max_value() - 22000) {
if result != 0 {
let _ = self.release_v_data(&DatAddr(result));
... | code_fim | hard | {
"lang": "rust",
"repo": "Sgeo/propdump2cell42",
"path": "/src/ctree.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Sgeo/propdump2cell42 path: /src/ctree.rs
#![allow(non_upper_case_globals)]
extern crate libloading as lib;
use std::os::raw::c_char;
use std::ffi::CString;
use std::fmt;
use std::error;
lazy_static! {
static ref CT: lib::Library = lib::Library::new("ctreestd.dll").unwrap();
static ... | code_fim | hard | {
"lang": "rust",
"repo": "Sgeo/propdump2cell42",
"path": "/src/ctree.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(unused_macros)]
macro_rules! warn {
($($arg:expr), *) => {
eprintln!("\x1b[31mWARNING:{}:{}: {}\x1b[0m", file!(), line!(), format! {$($arg), *});
};
}
#[allow(unused_macros)]
macro_rules! err {
($($arg:expr), *) => {
eprintln!("\x1b[31mERROR:{}:{}: {}\x1b[0m", file!(),... | code_fim | hard | {
"lang": "rust",
"repo": "jlinoff/json-fmt",
"path": "/src/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jlinoff/json-fmt path: /src/util.rs
//! Some useful utilities.
#![macro_use]
#[allow(unused_macros)]
macro_rules! info {
($($arg:expr), *) => {
println!("INFO:{}:{}: {}", file!(), line!(), format! {$($arg), *});
};
}
<|fim_suffix|>#[allow(unused_macros)]
macro_rules! warn {
... | code_fim | hard | {
"lang": "rust",
"repo": "jlinoff/json-fmt",
"path": "/src/util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: evandropoa/harmony path: /src/assets/mesh.rs
use super::{
file_manager::AssetHandle,
material::{PBRMaterial, PBRMaterialRon},
material_manager::MaterialManager,
};
use bytemuck::{Pod, Zeroable};
use nalgebra_glm::{Vec2, Vec3, Vec4};
use std::{
collections::HashMap,
ffi::OsStr... | code_fim | hard | {
"lang": "rust",
"repo": "evandropoa/harmony",
"path": "/src/assets/mesh.rs",
"mode": "psm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn set_tangent_encoded(&mut self, tangent: [f32; 4], face: usize, vert: usize) {
vertex_mut(self, face, vert).tangent = tangent.into();
}
}
#[cfg(test)]
mod tests {
use super::Gltf;
use crate::{
assets::{material_manager::MaterialManager, texture_manager::TextureManager},
... | code_fim | hard | {
"lang": "rust",
"repo": "evandropoa/harmony",
"path": "/src/assets/mesh.rs",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl mikktspace::Geometry for SubMesh {
fn num_faces(&self) -> usize {
self.indices.len() / 3
}
fn num_vertices_of_face(&self, _face: usize) -> usize {
3
}
fn position(&self, face: usize, vert: usize) -> [f32; 3] {
vertex(self, face, vert).position.into()
... | code_fim | hard | {
"lang": "rust",
"repo": "evandropoa/harmony",
"path": "/src/assets/mesh.rs",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|>t
.
block_on
(
async
{
task
:
:
yield_now
(
)
.
await
;
}
)
;
/
/
Drop
the
rt
drop
(
rt
)
;
}
#
[
test
]
fn
drop_tasks_in_context
(
)
{
static
SUCCESS
:
AtomicBool
=
AtomicBool
:
:
new
(
false
)
;
struct
ContextOnDrop
;
impl
Future
for
ContextOnDrop
{
type
Output
=
(
)
;
fn
poll
(
self
:
Pin
<
&
mut
Self
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tokio/tests/rt_basic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/tokio/tests/rt_basic.rs
#
!
[
warn
(
rust_2018_idioms
)
]
#
!
[
cfg
(
feature
=
"
full
"
)
]
use
tokio
:
:
runtime
:
:
Runtime
;
use
tokio
:
:
sync
:
:
oneshot
;
use
tokio
:
:
time
:
:
{
timeout
Duration
}
;
use
tokio_test
:
:
{
assert_err
asse... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tokio/tests/rt_basic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
)
;
assert_eq
!
(
out
"
ZOMG
"
)
;
cfg_metrics
!
{
let
metrics
=
rt
.
metrics
(
)
;
drop
(
rt
)
;
assert_eq
!
(
0
metrics
.
remote_schedule_count
(
)
)
;
let
mut
local
=
0
;
for
i
in
0
.
.
metrics
.
num_workers
(
)
{
local
+
=
metrics
.
worker_local_schedule_count
(
i
)
;
}
assert_eq
!
(
2
local
)
;
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/tokio/tests/rt_basic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: growingspaghetti/project-euler path: /rust/src/m7.rs
//! ```txt
//! ryoji@ubuntu:/media/dev/project-euler$ cargo bench --bench bench_main -- the_10001st_prime_number --verbose --baseline new
//! Finished bench [optimized] target(s) in 0.13s
//! Running target/release/deps/bench_main-e04... | code_fim | hard | {
"lang": "rust",
"repo": "growingspaghetti/project-euler",
"path": "/rust/src/m7.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in (prime * prime..sieve.len()).step_by(prime) {
sieve[i] = false;
}
}
// 928 us
// fn rule_out_from_previous_position(sieve: &mut Vec<bool>, prime: usize, pp: usize) {
// for i in (prime * prime..sieve.len()).step_by(prime) {
// if i < pp {
// continue;
// ... | code_fim | hard | {
"lang": "rust",
"repo": "growingspaghetti/project-euler",
"path": "/rust/src/m7.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> } else {
let mut val;
let server = get_server(guild_id, &mut *connection)?;
let name = subcommand.options.get(0).unwrap().value.as_ref().unwrap().as_str().unwrap();
match name {
"banter" => {
val = server.bante... | code_fim | hard | {
"lang": "rust",
"repo": "DarkZek/ChickenBot",
"path": "/src/commands/settings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DarkZek/ChickenBot path: /src/commands/settings.rs
use crate::commands::command::{Command, CommandInfoBuilder, CommandInfo, CommandCategory, AppContext};
use async_trait::async_trait;
use diesel::{ExpressionMethods, RunQueryDsl};
use lazy_static::lazy_static;
use serenity::builder::CreateApplica... | code_fim | hard | {
"lang": "rust",
"repo": "DarkZek/ChickenBot",
"path": "/src/commands/settings.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut changed_values = Vec::new();
if subcommand.name == "set" {
for option in &subcommand.options {
match option.name.as_str() {
"banter" => {
let value = option.value.as_ref().unwrap().as_str().unwrap_or("false").... | code_fim | hard | {
"lang": "rust",
"repo": "DarkZek/ChickenBot",
"path": "/src/commands/settings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tokcum/wasm-svg path: /lib/src/svg/class.rs
#[derive(Debug)]
pub enum Class {
Line,
Triangle,
Polyline,
Polygon,
}
impl Class {
pub fn to_string(&self) -> String {
match self {
Class::Line => <|fim_suffix|>n => format!("polygone"),
Class::Poly... | code_fim | medium | {
"lang": "rust",
"repo": "tokcum/wasm-svg",
"path": "/lib/src/svg/class.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>format!("line"),
Class::Triangle => format!("triangle"),
Class::Polygon => format!("polygone"),
Class::Polyline => format!("polyline"),
}
}
}<|fim_prefix|>// repo: tokcum/wasm-svg path: /lib/src/svg/class.rs
#[derive(Debug)]
pub enum Class {
Line,
T... | code_fim | medium | {
"lang": "rust",
"repo": "tokcum/wasm-svg",
"path": "/lib/src/svg/class.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xiongchengqing/kindle-dash path: /src/next-wakeup/src/main.rs
use cron::Schedule;
use chrono::Utc;
use chrono_tz::Tz;
const HELP: &str = "\
USAGE:
next-wakeup --schedule '0 2-32 8-18 * * 2,6' --timezone 'Europe/Amsterdam'
next-wakeup -s='0 2-32 8-18 * * 2,6' -tz='Europe/Amsterdam'
OPTIONS:... | code_fim | medium | {
"lang": "rust",
"repo": "xiongchengqing/kindle-dash",
"path": "/src/next-wakeup/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut pargs = pico_args::Arguments::from_env();
if pargs.contains(["-h", "--help"]) {
print!("{}", HELP);
std::process::exit(1);
}
let args = Args {
timezone: pargs.value_from_str(["-tz", "--timezone"])?,
schedule: pargs.value_from_str(["-s", "--schedule... | code_fim | medium | {
"lang": "rust",
"repo": "xiongchengqing/kindle-dash",
"path": "/src/next-wakeup/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if pargs.contains(["-h", "--help"]) {
print!("{}", HELP);
std::process::exit(1);
}
let args = Args {
timezone: pargs.value_from_str(["-tz", "--timezone"])?,
schedule: pargs.value_from_str(["-s", "--schedule"])?
};
Ok(args)
}<|fim_prefix|>// repo: xiong... | code_fim | hard | {
"lang": "rust",
"repo": "xiongchengqing/kindle-dash",
"path": "/src/next-wakeup/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Process whatever happened.
match results {
0 => {
// No events - must be a timeout. Tell c-ares about it.
ares_channel.process_fd(
c_ares::SOCKET_BAD,
c_ares::SOCKET_BAD);
},
_ =... | code_fim | hard | {
"lang": "rust",
"repo": "azdlowry/rust-c-ares",
"path": "/examples/unix/cares_event_loop.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // If we're not waiting for anything, we're done.
if tracked_fds.is_empty() { break }
// Wait for something to happen.
let timeout = Duration::from_millis(100);
let results = poll.poll(&mut events, Some(timeout))
.expect("poll failed");
// Proc... | code_fim | hard | {
"lang": "rust",
"repo": "azdlowry/rust-c-ares",
"path": "/examples/unix/cares_event_loop.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: azdlowry/rust-c-ares path: /examples/unix/cares_event_loop.rs
// This example uses a mio event loop to poll for readiness.
extern crate c_ares;
extern crate mio;
use std::collections::HashSet;
use std::error::Error;
use std::net::IpAddr;
use std::time::Duration;
fn print_host_results(result: c... | code_fim | hard | {
"lang": "rust",
"repo": "azdlowry/rust-c-ares",
"path": "/examples/unix/cares_event_loop.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Should spawn the `Future` returned by the `Executor::run`
/// to `Tokio::spawn`
#[async_trait]
pub trait Executor: Send + Sync {
async fn run(mut self: Box<Self>);
}<|fim_prefix|>// repo: lichen-liu/dv-in-rust path: /o2versioner/src/util/executor.rs
//! An executor to run as an individual task
<... | code_fim | easy | {
"lang": "rust",
"repo": "lichen-liu/dv-in-rust",
"path": "/o2versioner/src/util/executor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lichen-liu/dv-in-rust path: /o2versioner/src/util/executor.rs
//! An executor to run as an individual task
<|fim_suffix|>/// Should spawn the `Future` returned by the `Executor::run`
/// to `Tokio::spawn`
#[async_trait]
pub trait Executor: Send + Sync {
async fn run(mut self: Box<Self>);
}<... | code_fim | easy | {
"lang": "rust",
"repo": "lichen-liu/dv-in-rust",
"path": "/o2versioner/src/util/executor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match res {
Ok(user) => {
let user_string = serde_json::to_string(&user).unwrap();
id.remember(user_string);
Ok(HttpResponse::Ok().finish())
}
Err(err) => match err {
BlockingError::Error(service_error) => Err(service_error),
... | code_fim | hard | {
"lang": "rust",
"repo": "xplorer1/rust_auth_service",
"path": "/src/handlers/auth_handler.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xplorer1/rust_auth_service path: /src/handlers/auth_handler.rs
use actix_identity::Identity;
use actix_web::{
dev::Payload, error::BlockingError, web, Error, FromRequest,HttpRequest, HttpResponse
};
use diesel::prelude::*;
use diesel::PgConnection;
use futures::future::{err, ok, Ready};
use... | code_fim | hard | {
"lang": "rust",
"repo": "xplorer1/rust_auth_service",
"path": "/src/handlers/auth_handler.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adradek/sicp path: /1.22/timed_prime_test.rs
#[path= "../1.21/smallest_divisor.rs"]
mod smallest_divisor;
use std::time::{Duration, Instant};
<|fim_suffix|>fn report(n: i64) {
let start = Instant::now();
is_prime(n);
let duration = start.elapsed();
println!("{} is prime, elaps... | code_fim | hard | {
"lang": "rust",
"repo": "adradek/sicp",
"path": "/1.22/timed_prime_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return n == smallest_divisor::calc(n);
}
fn report(n: i64) {
let start = Instant::now();
is_prime(n);
let duration = start.elapsed();
println!("{} is prime, elapsed time is {:?}", n, duration);
}<|fim_prefix|>// repo: adradek/sicp path: /1.22/timed_prime_test.rs
#[path= "../1.21/sma... | code_fim | hard | {
"lang": "rust",
"repo": "adradek/sicp",
"path": "/1.22/timed_prime_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _g = setup_logger(config).unwrap();
let span_1 = tracing::error_span!("level", "first").entered();
let propagator = TraceContextPropagator::new();
// Act
let res = TelemetryContextInjector::get_trace_context_map(&span_1.context(), &propagator);
// Assert
let expected_tra... | code_fim | hard | {
"lang": "rust",
"repo": "WuerthPhoenix/tornado",
"path": "/common/logger/tests/should_get_span_context_carrier.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: WuerthPhoenix/tornado path: /common/logger/tests/should_get_span_context_carrier.rs
use opentelemetry::sdk::propagation::TraceContextPropagator;
use opentelemetry::trace::TraceContextExt;
use tornado_common_api::ValueExt;
use tornado_common_logger::elastic_apm::ApmTracingConfig;
use tornado_comm... | code_fim | medium | {
"lang": "rust",
"repo": "WuerthPhoenix/tornado",
"path": "/common/logger/tests/should_get_span_context_carrier.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> From<T> for Const<T> {
fn from(value: T) -> Self {
Self::new(value)
}
}
impl<T: Clone> Const<T> {
pub fn eval(&self) -> T {
self.value.clone()
}
}<|fim_prefix|>// repo: 1ybe/agora path: /node-plugin/lang/src/expressions/primitives.rs
use super::*;
use crate::coerc... | code_fim | hard | {
"lang": "rust",
"repo": "1ybe/agora",
"path": "/node-plugin/lang/src/expressions/primitives.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 1ybe/agora path: /node-plugin/lang/src/expressions/primitives.rs
use super::*;
use crate::coercion::Coerce;
use crate::graphql_utils::StaticValue;
use std::marker::PhantomData;
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
struct Unowned<T>(PhantomData<*const T>);
impl<T> Unowned<T> {
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "1ybe/agora",
"path": "/node-plugin/lang/src/expressions/primitives.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ben0x539/for_each_mod path: /src/lib.rs
#![feature(proc_macro_span)]
extern crate proc_macro;
use std::error::Error;
use std::fs;
use std::ffi::OsStr;
use proc_macro::{TokenStream, Span, TokenTree, Literal, Ident, Group};
type Result<T> = std::result::Result<T, Box<dyn Error>>;
#[proc_macro... | code_fim | medium | {
"lang": "rust",
"repo": "ben0x539/for_each_mod",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn replace<'a>(input: TokenStream, subst: &'a str) -> impl Iterator<Item=TokenTree>+'a {
input.into_iter().map(move |token| match token {
TokenTree::Ident(ident) if ident.to_string() == "PLACEHOLDER" =>
TokenTree::Ident(Ident::new(subst, ident.span())),
TokenTree::Literal(l... | code_fim | hard | {
"lang": "rust",
"repo": "ben0x539/for_each_mod",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> input.into_iter().map(move |token| match token {
TokenTree::Ident(ident) if ident.to_string() == "PLACEHOLDER" =>
TokenTree::Ident(Ident::new(subst, ident.span())),
TokenTree::Literal(lit) if lit.to_string().starts_with("\"") => {
let mut new_lit: Literal = lit.... | code_fim | hard | {
"lang": "rust",
"repo": "ben0x539/for_each_mod",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: coreylowman/projectEuler path: /src/problems/problem002.rs
struct Pair {
pub t: u64,
pub x: u64,
pub cur: u64,
pub max: u64,
}
<|fim_suffix|> fn next(&mut self) -> Option<u64> {
if self.cur >= self.max {
return None;
}
let t: u64 = self.t;
... | code_fim | medium | {
"lang": "rust",
"repo": "coreylowman/projectEuler",
"path": "/src/problems/problem002.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut sum: u64 = 0;
let fpair = Pair {
t: 1,
x: 1,
cur: 1,
max: 4000000,
};
for x in fpair {
if x > 4000000 {
break;
}
if x % 2 == 0 {
sum += x;
}
}
sum.to_string()
}
problem!(go, 4613732);<... | code_fim | medium | {
"lang": "rust",
"repo": "coreylowman/projectEuler",
"path": "/src/problems/problem002.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JoshOlds/Advent_of_Code_2020 path: /advent_libs/src/input_helpers.rs
use std::fmt::Debug;
use std::{fs, str::FromStr};
/// Accepts a given day number as an integer, and returns a string containing the puzzle input for that day.
///
/// The expectation is that the terminal executing this functio... | code_fim | hard | {
"lang": "rust",
"repo": "JoshOlds/Advent_of_Code_2020",
"path": "/advent_libs/src/input_helpers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod tests {
#[cfg(test)]
use crate::input_helpers::read_puzzle_input_to_string;
#[test]
fn test_read_puzzle_input_to_string() {
let _input = read_puzzle_input_to_string(1);
}
}<|fim_prefix|>// repo: JoshOlds/Advent_of_Code_2020 path: /advent_libs/src/input_helpers.rs
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "JoshOlds/Advent_of_Code_2020",
"path": "/advent_libs/src/input_helpers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/cm path: /src/cm/key_stroke.rs
use ncurses::*;
use std::str::FromStr;
pub const KEY_ESCAPE: i32 = 0x1B;
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
pub struct KeyStroke {
pub key: i32,
pub alt: bool,
}
impl KeyStroke {
pub fn get() -> Option<Self> {
... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/cm",
"path": "/src/cm/key_stroke.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match split(s, ':').as_slice() {
["key", params] => match split(params, ',').as_slice() {
[key, "alt"] => {
let key_code = key_of_name(key)?;
Ok(KeyStroke {
key: key_code,
alt: true,... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/cm",
"path": "/src/cm/key_stroke.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: olson-sean-k/plexus path: /pictor/src/renderer.rs
use wgpu::{
Adapter, BackendBit, Device, DeviceDescriptor, Instance, PresentMode, Queue,
RequestAdapterOptions, Surface, SwapChain, SwapChainDescriptor, TextureFormat, TextureUsage,
};
use winit::window::Window;
use crate::harness::{Conf... | code_fim | hard | {
"lang": "rust",
"repo": "olson-sean-k/plexus",
"path": "/pictor/src/renderer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.queue
}
fn swap_chain_descriptor(&self) -> &SwapChainDescriptor {
&self.swap_chain_descriptor
}
}
impl RenderStage for Renderer {
fn device(&self) -> &Device {
&self.device
}
fn queue(&self) -> &Queue {
&self.queue
}
}<|fim_prefix|>// re... | code_fim | hard | {
"lang": "rust",
"repo": "olson-sean-k/plexus",
"path": "/pictor/src/renderer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn swap_chain_descriptor(&self) -> &SwapChainDescriptor {
&self.swap_chain_descriptor
}
}
impl RenderStage for Renderer {
fn device(&self) -> &Device {
&self.device
}
fn queue(&self) -> &Queue {
&self.queue
}
}<|fim_prefix|>// repo: olson-sean-k/plexus pa... | code_fim | hard | {
"lang": "rust",
"repo": "olson-sean-k/plexus",
"path": "/pictor/src/renderer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_profile_most_probable_kmer(
text: &str,
k: usize,
profile_matrix: &Array2<f64>,
) -> String {
let text: Vec<_> = text.chars().collect();
let mut max_probability = -1.;
let mut max_kmer = String::new();
for i in 0..=(text.len() - k) {
let text_kmer: String = t... | code_fim | hard | {
"lang": "rust",
"repo": "Ninjani/rosalind",
"path": "/t_ba2c/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ninjani/rosalind path: /t_ba2c/src/lib.rs
use std::collections::HashMap;
use std::path::Path;
use anyhow::Error;
use ndarray::Array2;
use utility::io::Parseable;
pub fn rosalind_ba2c(filename: &Path) -> Result<(), Error> {
let contents = utility::io::input_from_file(filename)?;
let mu... | code_fim | hard | {
"lang": "rust",
"repo": "Ninjani/rosalind",
"path": "/t_ba2c/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> k as usize {
if (arr[i] - arr[m]).abs() > (arr[j] - arr[m]).abs() {
ret.push(arr[i]);
i += 1;
} else {
ret.push(arr[j]);
j -= 1;
}
}
ret
}
}<|fim_prefix|>// repo: Telixia/leetcode-3 p... | code_fim | hard | {
"lang": "rust",
"repo": "Telixia/leetcode-3",
"path": "/Medium/1471-The k Strongest Values in an Array/Sort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Telixia/leetcode-3 path: /Medium/1471-The k Strongest Values in an Array/Sort.rs
impl Solution {
pub fn get_strongest(mut arr: Vec<i32>, k: i32) -> Vec<i32> {
arr.sort_unstable();
let m = (arr<|fim_suffix|> k as usize {
if (arr[i] - arr[m]).abs() > (arr[j] - arr[m... | code_fim | hard | {
"lang": "rust",
"repo": "Telixia/leetcode-3",
"path": "/Medium/1471-The k Strongest Values in an Array/Sort.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/rustversion/v1/crate/build/build.rs
#![allow(
clippy::enum_glob_use,
clippy::must_use_candidate,
clippy::single_match_else
)]
mod rustc;
use std::env;
use std::ffi::OsString;
use std::fs;
use std::path::Path;
use std::process::{self, Comman... | code_fim | hard | {
"lang": "rust",
"repo": "chromium/chromium",
"path": "/third_party/rust/rustversion/v1/crate/build/build.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let version = match rustc::parse(&string) {
Some(version) => version,
None => {
eprintln!(
"Error: unexpected output from `rustc --version`: {:?}\n\n\
Please file an issue in https://github.com/dtolnay/rustversion",
string
... | code_fim | hard | {
"lang": "rust",
"repo": "chromium/chromium",
"path": "/third_party/rust/rustversion/v1/crate/build/build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: semtexzv/dp path: /code/deps/actix-comm/src/base/sub.rs
use crate::prelude::*;
use crate::msg::*;
use crate::ctx::ContextHandle;
use crate::util::*;
pub struct Subscribe {
handle: crate::ctx::ContextHandle,
registry: crate::util::HandlerRegistry,
}
impl Actor for Subscribe { type Con... | code_fim | hard | {
"lang": "rust",
"repo": "semtexzv/dp",
"path": "/code/deps/actix-comm/src/base/sub.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match msg {
MessageWrapper::Announcement(typ, data) => {
if let Some(handler) = self.registry.get(&typ) {
let (tx, rx) = oneshot();
handler.handle(typ, data, tx);
let rx = rx.map_err(|_| RemoteError::MailboxClo... | code_fim | hard | {
"lang": "rust",
"repo": "semtexzv/dp",
"path": "/code/deps/actix-comm/src/base/sub.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: OpenXiangShan/rust-xs-evaluation path: /tests/am_cachetests/src/cachetests/mod.rs
/// nexus-am cachetests
pub mod access;
<|fim_suffix|>const BENCH_SIZE: usize = 20;
pub fn test_all() -> Vec<Result<String, CacheTestErr>> {
let mut access_test = access::AccessTest::new();
let results =... | code_fim | medium | {
"lang": "rust",
"repo": "OpenXiangShan/rust-xs-evaluation",
"path": "/tests/am_cachetests/src/cachetests/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn test_all() -> Vec<Result<String, CacheTestErr>> {
let mut access_test = access::AccessTest::new();
let results = vec![
access_test.single_test(),
access_test.bench_test(BENCH_SIZE),
];
results
}<|fim_prefix|>// repo: OpenXiangShan/rust-xs-evaluation path: /tests/am_... | code_fim | easy | {
"lang": "rust",
"repo": "OpenXiangShan/rust-xs-evaluation",
"path": "/tests/am_cachetests/src/cachetests/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn fold(s: State, e: Event) -> State {
State {
id: s.id,
name: e.name,
}
}<|fim_prefix|>// repo: marcusradell/lab_rust_event_sourcing path: /src/product/name_changed.rs
use super::State;
<|fim_middle|>#[derive(Debug)]
pub struct Event {
pub name: String,
}
| code_fim | medium | {
"lang": "rust",
"repo": "marcusradell/lab_rust_event_sourcing",
"path": "/src/product/name_changed.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marcusradell/lab_rust_event_sourcing path: /src/product/name_changed.rs
use super::State;
<|fim_suffix|>pub fn fold(s: State, e: Event) -> State {
State {
id: s.id,
name: e.name,
}
}<|fim_middle|>#[derive(Debug)]
pub struct Event {
pub name: String,
}
| code_fim | medium | {
"lang": "rust",
"repo": "marcusradell/lab_rust_event_sourcing",
"path": "/src/product/name_changed.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m4b/goblin path: /src/elf/symver.rs
inition` section.
let (offset, size, count) =
if let Some(shdr) = shdrs.iter().find(|shdr| shdr.sh_type == SHT_GNU_VERDEF) {
(
shdr.sh_offset as usize,
shdr.sh_size as usize,
... | code_fim | hard | {
"lang": "rust",
"repo": "m4b/goblin",
"path": "/src/elf/symver.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m4b/goblin path: /src/elf/symver.rs
eneric/LSB-Core-generic/symversion.html#VERDEFEXTS
#[repr(C)]
#[derive(Debug, Pread)]
struct ElfVerdaux {
vda_name: u32,
vda_next: u32,
}
/// An ELF `Version Need` entry Elfxx_Verneed.
///
/// https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/... | code_fim | hard | {
"lang": "rust",
"repo": "m4b/goblin",
"path": "/src/elf/symver.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Iterator over the [`Verneed`] entries from the [`SHT_GNU_VERNEED`] section.
pub struct VerneedIter<'a> {
bytes: &'a [u8],
count: usize,
index: usize,
offset: usize,
ctx: container::Ctx,
}
impl<'a> Iterator for VerneedIter<'a> {
type Item = Verneed<'a>;
fn next(&mut self) ... | code_fim | hard | {
"lang": "rust",
"repo": "m4b/goblin",
"path": "/src/elf/symver.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hkarim/note_effects_vst path: /util/src/lib.rs
extern crate global_counter;
use vst::event::MidiEvent;
use vst::plugin::HostCallback;
pub mod constants;
pub mod debug;
pub mod parameter_value_conversion;
pub mod parameters;
pub mod messages;
pub mod absolute_time_midi_message;
pub mod midi_mes... | code_fim | medium | {
"lang": "rust",
"repo": "hkarim/note_effects_vst",
"path": "/util/src/lib.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn duration_display(value: f32) -> String {
let mut out = String::new();
let mut _value = value;
if _value >= 1.0 {
out += &*format!("{:.0}s ", value);
_value -= value.trunc();
}
if _value > 0.0 {
out += &*format!("{:3.0}ms", value * 1000.0);
}
out
}... | code_fim | hard | {
"lang": "rust",
"repo": "hkarim/note_effects_vst",
"path": "/util/src/lib.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.