text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>/// A Cache of fallback textures that uses the sample count as a key
///
/// # WARNING
/// Images using MSAA with sample count > 1 are not initialized with data, therefore,
/// you shouldn't sample them before writing data to them first.
#[derive(Resource, Deref, DerefMut, Default)]
pub struct FallbackIma... | code_fim | hard | {
"lang": "rust",
"repo": "bevyengine/bevy",
"path": "/crates/bevy_render/src/texture/fallback_image.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yutiansut/clickhouse-rs-1 path: /clickhouse-http-client/tests/integration_tests.rs
#[cfg(feature = "_integration_tests")]
#[path = "integration_tests"]
mod integration_tests {
mod helpers;
<|fim_suffix|> #[cfg(test)]
mod curd;
}<|fim_middle|> #[cfg(test)]
mod ping;
| code_fim | easy | {
"lang": "rust",
"repo": "yutiansut/clickhouse-rs-1",
"path": "/clickhouse-http-client/tests/integration_tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(test)]
mod curd;
}<|fim_prefix|>// repo: yutiansut/clickhouse-rs-1 path: /clickhouse-http-client/tests/integration_tests.rs
#[cfg(feature = "_integration_tests")]
#[path = "integration_tests"]
mod integration_tests {
mod helpers;
<|fim_middle|> #[cfg(test)]
mod ping;
| code_fim | easy | {
"lang": "rust",
"repo": "yutiansut/clickhouse-rs-1",
"path": "/clickhouse-http-client/tests/integration_tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wezm/dslite2svd path: /crates/tm4c129x/src/emac0/pmtctlstat/mod.rs
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::PMTCTLSTAT {
#[doc = r" Modifies the contents of the register"]... | code_fim | hard | {
"lang": "rust",
"repo": "wezm/dslite2svd",
"path": "/crates/tm4c129x/src/emac0/pmtctlstat/mod.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_suffix|> ((self.bits >> OFFSET) & MASK as u32) != 0
};
MGKPKTENR { bits }
}
#[doc = "Bit 2 - Wake-Up Frame Enable"]
#[inline]
pub fn wupfren(&self) -> WUPFRENR {
let bits = {
const MASK: bool = true;
const OFFSET: u8 = 2;
((self.bi... | code_fim | hard | {
"lang": "rust",
"repo": "wezm/dslite2svd",
"path": "/crates/tm4c129x/src/emac0/pmtctlstat/mod.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: carliengineer/rustBook path: /smart_pointers/src/main.rs
use std::ops::Deref;
use std::mem::drop;
//Box<T>. Boxes allow you to store data on the heap rather than the stack. What remains on the stack is the pointer to the heap data
//Boxes don’t have performance overhead, other than storing thei... | code_fim | hard | {
"lang": "rust",
"repo": "carliengineer/rustBook",
"path": "/smart_pointers/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>//implement deref trait to enable dereferencing with * operator
//to implement a trait, we need to provide implementations for the trait’s required methods
//The Deref trait, provided by the standard library, requires us to implement
// one method named deref that borrows self and returns a reference to t... | code_fim | hard | {
"lang": "rust",
"repo": "carliengineer/rustBook",
"path": "/smart_pointers/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
//Reference counter. for multiple owners of same data. works only with single thread programs
use std::rc::Rc;
use crate::List2::{Cons as RcCons, Nil as RcNil};
enum List2 {
Cons(i32, Rc<List2>),
Nil,
}
fn main() {
//Boxes provide only the indirection and heap allocation; they don’t ... | code_fim | hard | {
"lang": "rust",
"repo": "carliengineer/rustBook",
"path": "/smart_pointers/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ahenshaw/aoc2020rs path: /src/template.rs
use aoc_runner_derive::aoc_generator;
use sscanf::scanf;
<|fim_suffix|>#[aoc_generator(day#)]
pub fn input_generator(input: &str) -> Vec<Input> {
input.lines().map(|line| {
let (a) = scanf!(line, "{}", usize).unwrap();
Input{a... | code_fim | medium | {
"lang": "rust",
"repo": "ahenshaw/aoc2020rs",
"path": "/src/template.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[aoc(day#, part2)]
pub fn solve_part2(input: &[Input]) -> u32 {
for a in input {
}
0
}<|fim_prefix|>// repo: ahenshaw/aoc2020rs path: /src/template.rs
use aoc_runner_derive::aoc_generator;
use sscanf::scanf;
#[derive(Debug)]
pub struct Input {
a: usize,
}
<|fim_middle|>#[a... | code_fim | hard | {
"lang": "rust",
"repo": "ahenshaw/aoc2020rs",
"path": "/src/template.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &item.expr_id,
ir_program,
mir_program,
unifier,
function_queue,
typedef_store,
expr_id_map,
pattern_id_map,
... | code_fim | hard | {
"lang": "rust",
"repo": "jaffa4/siko-1",
"path": "/crates/siko_backend/src/expr_processor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jaffa4/siko-1 path: /crates/siko_backend/src/expr_processor.rs
use crate::class_member_processor::process_class_member_call;
use crate::function_queue::CallContext;
use crate::function_queue::FunctionQueue;
use crate::function_queue::FunctionQueueItem;
use crate::pattern_processor::process_patte... | code_fim | hard | {
"lang": "rust",
"repo": "jaffa4/siko-1",
"path": "/crates/siko_backend/src/expr_processor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexander-smoktal/rust-patterns path: /src/behavioral/chain_of_responsibility.rs
#[derive(Debug, Clone)]
pub enum Currency {
Bitcoin(f32),
Etherium(f32),
USD(f32),
Invalid,
}
#[derive(Debug)]
pub struct NotFound;
pub trait CurrencyPrinter {
fn new() -> Self
where
... | code_fim | hard | {
"lang": "rust",
"repo": "alexander-smoktal/rust-patterns",
"path": "/src/behavioral/chain_of_responsibility.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
}
pub struct EtheriumPrinter;
type ETHPrinter = PrinterWrapper<EtheriumPrinter>;
impl CurrencyPrinter for EtheriumPrinter {
fn new() -> Self {
EtheriumPrinter
}
fn print(&self, currency: Currency) -> Result<(), NotFound> {
match currency {
Currency::Etherium... | code_fim | hard | {
"lang": "rust",
"repo": "alexander-smoktal/rust-patterns",
"path": "/src/behavioral/chain_of_responsibility.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(Solution::simplify_path("/home/"), "/home");
assert_eq!(Solution::simplify_path("/../"), "/");
assert_eq!(Solution::simplify_path("/home//foo/"), "/home/foo");
assert_eq!(Solution::simplify_path("/a/./b/../../c/"), "/c");
assert_eq!(Solution::simplify_path("/a/../../b/../c//... | code_fim | hard | {
"lang": "rust",
"repo": "hbina/leetcode-solutions",
"path": "/leetcode_rust/src/leetcode/problem_71.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hbina/leetcode-solutions path: /leetcode_rust/src/leetcode/problem_71.rs
use crate::Solution;
impl Solution {
pub fn simplify_path<T>(path: T) -> String
where
T: Into<String>,
{
let mut stack: Vec<&str> = Vec::new();
let path = path.into();
path.split... | code_fim | hard | {
"lang": "rust",
"repo": "hbina/leetcode-solutions",
"path": "/leetcode_rust/src/leetcode/problem_71.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gala377/Auster path: /eurus/src/service/dto.rs
use serde::{Deserialize, Serialize};
<|fim_suffix|>#[derive(Debug, Serialize)]
pub struct NewPlayerReq {
id: usize,
password: u64,
name: String,
}<|fim_middle|>#[derive(Debug, Deserialize)]
pub struct NewRoomReq {
pub players_limit:... | code_fim | hard | {
"lang": "rust",
"repo": "gala377/Auster",
"path": "/eurus/src/service/dto.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Serialize)]
pub struct NewPlayerReq {
id: usize,
password: u64,
name: String,
}<|fim_prefix|>// repo: gala377/Auster path: /eurus/src/service/dto.rs
use serde::{Deserialize, Serialize};
<|fim_middle|>#[derive(Debug, Deserialize)]
pub struct NewRoomReq {
pub players_limit:... | code_fim | hard | {
"lang": "rust",
"repo": "gala377/Auster",
"path": "/eurus/src/service/dto.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gala377/Auster path: /eurus/src/service/dto.rs
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize)]
pub struct NewRoomReq {
pub players_limit: usize,
pub rounds_limit: usize,
}
<|fim_suffix|>#[derive(Debug, Serialize)]
pub struct NewPlayerReq {
id: usize,
password... | code_fim | medium | {
"lang": "rust",
"repo": "gala377/Auster",
"path": "/eurus/src/service/dto.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let client_factory = mongodb::ClientFactory::new("mongodb://localhost:\
27017/"
.to_string(),
"tags".to_string());
let mut client = cl... | code_fim | hard | {
"lang": "rust",
"repo": "sdukshis/tsdb-bench",
"path": "/src/query_perf.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sdukshis/tsdb-bench path: /src/query_perf.rs
#[macro_use]
extern crate log;
extern crate env_logger;
#[macro_use]
extern crate bson;
use std::time::{Instant, Duration};
use std::env;
use std::f64;
mod experiment;
use experiment::*;
mod clients;
use clients::*;
fn main() {
env_logger::i... | code_fim | hard | {
"lang": "rust",
"repo": "sdukshis/tsdb-bench",
"path": "/src/query_perf.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wmmxk/OOP_Rust path: /iterator/methods/type_hint.rs
// This is to get a taste of methods offered by an iterator
//source: https://killercup.github.io/trpl-ebook/trpl-2016-10-01.html#sec--iterators
// the ::<> syntax allows us to give a type hint, Otherwise Rust can't determine what type of thing... | code_fim | easy | {
"lang": "rust",
"repo": "wmmxk/OOP_Rust",
"path": "/iterator/methods/type_hint.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let range = (0..10).collect::<Vec<i32>>();
println!("{:?}", &range[..5]);
println!("{:?}", &range[2..5]);
println!("{:?}", &range[7..]);
}<|fim_prefix|>// repo: wmmxk/OOP_Rust path: /iterator/methods/type_hint.rs
// This is to get a taste of methods offered by an iterator
//source: https:... | code_fim | easy | {
"lang": "rust",
"repo": "wmmxk/OOP_Rust",
"path": "/iterator/methods/type_hint.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut input: Vec<char> = vec!['h', 'e', 'l', 'l', 'o'];
let output: Vec<char> = vec!['o', 'l', 'l', 'e', 'h'];
Solution::reverse_string(&mut input);
assert_eq!(input, output);
}
}<|fim_prefix|>// repo: Latias94/rust-practice path: /leetcode/src/s0344_reverse_string.r... | code_fim | medium | {
"lang": "rust",
"repo": "Latias94/rust-practice",
"path": "/leetcode/src/s0344_reverse_string.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Latias94/rust-practice path: /leetcode/src/s0344_reverse_string.rs
struct Solution;
//leetcode submit region begin(Prohibit modification and deletion)
impl Solution {
pub fn reverse_string(s: &mut Vec<char>) {
if s.is_empty() {
return;
}
let mut left = 0;... | code_fim | medium | {
"lang": "rust",
"repo": "Latias94/rust-practice",
"path": "/leetcode/src/s0344_reverse_string.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: msehnout/libresolv path: /src/wire/msg.rs
use std::convert::TryFrom;
use std::net::Ipv4Addr;
use nom::{be_u8, be_u16, be_u32, IResult, Needed};
use defs::TYPE;
use error::Error;
use message::{Header, Message, Question, QuestionBuilder};
use rr::{Rdata, ResRec, ResRecBuilder};
/// Each label i... | code_fim | hard | {
"lang": "rust",
"repo": "msehnout/libresolv",
"path": "/src/wire/msg.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>named!(pub parse_dns_name_unit<NameUnit>, alt!(parse_dns_name_pointer | parse_dns_name_label));
named!(pub parse_dns_name_bottom<NameUnit>, alt!(
map!(tag!("\0"), |_| {NameUnit::End})
| parse_dns_name_pointer));
named!(pub parse_dns_name<Vec<NameUnit> >, map!(
many_till!(parse_dn... | code_fim | hard | {
"lang": "rust",
"repo": "msehnout/libresolv",
"path": "/src/wire/msg.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_response(
&self,
request: &Request,
params: &HashMap<String, Option<String>>,
) -> Response {
return Response::new();
}
}<|fim_prefix|>// repo: zprobst/oxidize path: /src/views.rs
use crate::routing::{Request, Response};
use std::collections::HashMap... | code_fim | medium | {
"lang": "rust",
"repo": "zprobst/oxidize",
"path": "/src/views.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zprobst/oxidize path: /src/views.rs
use crate::routing::{Request, Response};
use std::collections::HashMap;
<|fim_suffix|> pub fn get_response(
&self,
request: &Request,
params: &HashMap<String, Option<String>>,
) -> Response {
return Response::new();
... | code_fim | medium | {
"lang": "rust",
"repo": "zprobst/oxidize",
"path": "/src/views.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Prints to the standard error only in debug build.
/// In release build this macro is not compiled thanks to `#[cfg(debug_assertions)]`.
/// see [https://doc.rust-lang.org/std/macro.eprint.html](https://doc.rust-lang.org/std/macro.eprint.html) for more info.
#[macro_export]
macro_rules! debug_eprin... | code_fim | hard | {
"lang": "rust",
"repo": "RustyNixieTube/debug_print",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustyNixieTube/debug_print path: /src/lib.rs
/*!
## This crate provide prints macros that are not compiled in releases builds.
### Basic Examples
```
use debug_print::{debug_print, debug_println, debug_eprint, debug_eprintln};
let x = 5 * 2;
debug_println!("x = {}", x);
debug_print!("x");
deb... | code_fim | hard | {
"lang": "rust",
"repo": "RustyNixieTube/debug_print",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kbz/beatmap-repo path: /datafiles/m_003_easy.rs
{"song_name":"Snow halation","difficulty":1,"rank_info":[{"rank":5,"rank_max":7451},{"rank":4,"rank_max":11177},{"rank":3,"rank_max":14903},{"rank":2,"rank_max":18629},{"rank":1,"rank_max":0}],"song_info":[{"notes_speed":1.6,"notes":[{"timing_sec"... | code_fim | hard | {
"lang": "rust",
"repo": "kbz/beatmap-repo",
"path": "/datafiles/m_003_easy.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>:3},{"timing_sec":81.145,"effect":4,"effect_value":1.387,"position":6},{"timing_sec":83.573,"effect":1,"effect_value":2.0,"position":1},{"timing_sec":84.96,"effect":1,"effect_value":2.0,"position":2},{"timing_sec":86.348,"effect":1,"effect_value":2.0,"position":3},{"timing_sec":87.735,"effect":1,"effect_v... | code_fim | hard | {
"lang": "rust",
"repo": "kbz/beatmap-repo",
"path": "/datafiles/m_003_easy.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>,"position":2},{"timing_sec":61.376,"effect":1,"effect_value":2.0,"position":3},{"timing_sec":62.07,"effect":1,"effect_value":2.0,"position":4},{"timing_sec":62.764,"effect":1,"effect_value":2.0,"position":5},{"timing_sec":63.111,"effect":1,"effect_value":2.0,"position":5},{"timing_sec":64.845,"effect":1,... | code_fim | hard | {
"lang": "rust",
"repo": "kbz/beatmap-repo",
"path": "/datafiles/m_003_easy.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
fn get_intersection(remote_branches: &[GitBranch], local_branches: &[GitBranch]) -> Vec<GitBranch> {
local_branches
.iter()
.cloned()
.filter(|branch| {
remote_branches
.iter()
.any(|remote_branch| branch.name == remote_... | code_fim | hard | {
"lang": "rust",
"repo": "jamiebrynes7/git-tools",
"path": "/src/bin/clean_branches.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jamiebrynes7/git-tools path: /src/bin/clean_branches.rs
use git::*;
use structopt::StructOpt;
use std::io::{self, Write};
#[derive(Debug, StructOpt)]
#[structopt(
name = "git-clean-branches",
about = "Clean remote and local branches."
)]
struct Arguments {
/// Denotes whether to li... | code_fim | hard | {
"lang": "rust",
"repo": "jamiebrynes7/git-tools",
"path": "/src/bin/clean_branches.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //start an event loop
loop {
// Poll Mio for events, blocking util we get an event.
poll.poll(&mut events, None)?;
//Process each event
for event in events.iter() {
// We can use the token we previousy provided to 'register' to
// determine ... | code_fim | hard | {
"lang": "rust",
"repo": "zzl133/my_rust_road",
"path": "/rust-project/rust_project/learn-networking-programming/mio-example/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zzl133/my_rust_road path: /rust-project/rust_project/learn-networking-programming/mio-example/src/main.rs
use std::error::Error;
use mio::net::{TcpListener, TcpStream};
use mio::{Events, Interest, Poll, Token};
//Some tokens to allow us to identify which evnent is for which socket.
const SERVE... | code_fim | hard | {
"lang": "rust",
"repo": "zzl133/my_rust_road",
"path": "/rust-project/rust_project/learn-networking-programming/mio-example/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //Since the server just shuts down the connection, let's
//just exit from our event loop.
return Ok(());
}
*/
// We don't expect any events with tokens other than those we provide.
_... | code_fim | hard | {
"lang": "rust",
"repo": "zzl133/my_rust_road",
"path": "/rust-project/rust_project/learn-networking-programming/mio-example/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jadestrong/pandadoodle-rust-wasm path: /src/engine/ui/ui_sprite.rs
use crate::engine::effect::*;
use crate::engine::ui::*;
use crate::engine::*;
use std::ops::Deref;
pub struct UiSprite<C: ContextTrait + ?Sized> {
pub element: UiElement<C>,
pub texture: RefCell<Rc<Texture>>,
pub size: Sh... | code_fim | hard | {
"lang": "rust",
"repo": "jadestrong/pandadoodle-rust-wasm",
"path": "/src/engine/ui/ui_sprite.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let absolute_params = self.get_absolute_params(context);
if !absolute_params.visible {
return;
}
context.draw_ui_viewport(DrawImageArgs {
source: DrawSource::Texture(self.texture.borrow().clone()),
position: absolute_params.position,
size: *self.size.borrow(),
... | code_fim | hard | {
"lang": "rust",
"repo": "jadestrong/pandadoodle-rust-wasm",
"path": "/src/engine/ui/ui_sprite.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> context.draw_ui_viewport(DrawImageArgs {
source: DrawSource::Texture(self.texture.borrow().clone()),
position: absolute_params.position,
size: *self.size.borrow(),
depth: absolute_params.depth,
optional: DrawImageOptionalArgs {
color: *self.color.borrow(),
... | code_fim | hard | {
"lang": "rust",
"repo": "jadestrong/pandadoodle-rust-wasm",
"path": "/src/engine/ui/ui_sprite.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Scheduled for Reference {
fn scheduler(&self) -> Option<Arc<Scheduler>> {
Scheduler::from_id(&self.scheduler_id())
}
}
*/<|fim_prefix|>// repo: shaneutt/lumen path: /runtimes/core/src/scheduler.rs
use std::sync::Arc;
use liblumen_alloc::erts::scheduler::id;
use liblumen_alloc::erts:... | code_fim | medium | {
"lang": "rust",
"repo": "shaneutt/lumen",
"path": "/runtimes/core/src/scheduler.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shaneutt/lumen path: /runtimes/core/src/scheduler.rs
use std::sync::Arc;
use liblumen_alloc::erts::scheduler::id;
use liblumen_alloc::erts::term::prelude::ReferenceNumber;
use liblumen_core::locks::RwLock;
<|fim_suffix|>
/// Gets the current thread's timer wheel
fn hierarchy(&self) -> ... | code_fim | medium | {
"lang": "rust",
"repo": "shaneutt/lumen",
"path": "/runtimes/core/src/scheduler.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/*
impl Scheduled for Process {
fn scheduler(&self) -> Option<Arc<Scheduler>> {
self.scheduler_id()
.and_then(|scheduler_id| Scheduler::from_id(&scheduler_id))
}
}
impl Scheduled for Reference {
fn scheduler(&self) -> Option<Arc<Scheduler>> {
Scheduler::from_id(&se... | code_fim | hard | {
"lang": "rust",
"repo": "shaneutt/lumen",
"path": "/runtimes/core/src/scheduler.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Frizi/norays path: /src/math/mod.rs
mod aabb;
mod bounding_volume;
mod float;
mod point;
mod point2d;
mod ray<|fim_suffix|>e::*;
pub use self::float::*;
pub use self::point::*;
pub use self::point2d::*;
pub use self::ray::*;
pub use self::uv::*;
pub use self::vector::*;<|fim_middle|>;
mod uv;
mo... | code_fim | medium | {
"lang": "rust",
"repo": "Frizi/norays",
"path": "/src/math/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>e::*;
pub use self::float::*;
pub use self::point::*;
pub use self::point2d::*;
pub use self::ray::*;
pub use self::uv::*;
pub use self::vector::*;<|fim_prefix|>// repo: Frizi/norays path: /src/math/mod.rs
mod aabb;
mod bounding_volume;
mod float;
mod point;
mod point2d;
mod ray<|fim_middle|>;
mod uv;
mo... | code_fim | medium | {
"lang": "rust",
"repo": "Frizi/norays",
"path": "/src/math/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Smallest common multiple factors: {:#?}", scm);
println!("As value: {}", scm.factorisation().n)
}<|fim_prefix|>// repo: drdozer/euler_rust path: /euler_5/src/main.rs
use itertools::Itertools;
use hypatia::numbers::{Factor, Primes};
fn main() {
let mut primes = Primes::default();
... | code_fim | hard | {
"lang": "rust",
"repo": "drdozer/euler_rust",
"path": "/euler_5/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Using smallest common multiple
let fact_2 = primes.factorise(2);
let scm = (3..=20)
.map(|n| primes.factorise(n).factors)
.fold(fact_2.factors, |l, r| l.smallest_common_multiple(&r));
println!("Smallest common multiple factors: {:#?}", scm);
println!("As value: ... | code_fim | hard | {
"lang": "rust",
"repo": "drdozer/euler_rust",
"path": "/euler_5/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: drdozer/euler_rust path: /euler_5/src/main.rs
use itertools::Itertools;
use hypatia::numbers::{Factor, Primes};
fn main() {
let mut primes = Primes::default();
// manually implemented
// let mut all_factors: Vec<Factor> = (1..=20)
// .map(|n| primes.factorise(n))
// ... | code_fim | hard | {
"lang": "rust",
"repo": "drdozer/euler_rust",
"path": "/euler_5/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Board {
fn extent_at_time(&self, t: i64) -> Extent {
Extent {
x_min: self
.0
.iter()
.map(|l| l.position_at_time(t).0)
.min()
.unwrap(),
x_max: self
.0
.... | code_fim | hard | {
"lang": "rust",
"repo": "duncanfinney/advent-of-code-2018",
"path": "/src/day10.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn parse_input(input: &str) -> Board {
let lights = input
.lines()
.map(|l| {
lazy_static! {
static ref NUMBER_RE: Regex = Regex::new(r"-?\d+").unwrap();
};
let mut iter = NUMBER_RE.captures_iter(l);
let mut next_num_plea... | code_fim | hard | {
"lang": "rust",
"repo": "duncanfinney/advent-of-code-2018",
"path": "/src/day10.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: duncanfinney/advent-of-code-2018 path: /src/day10.rs
use lazy_static::*;
use regex::Regex;
pub fn solve() {
let input = include_str!("../input/day10");
let mut input = parse_input(input);
let mut t = 1i64;
let mut last_area = std::i64::MAX;
while last_area >= input.extent_a... | code_fim | hard | {
"lang": "rust",
"repo": "duncanfinney/advent-of-code-2018",
"path": "/src/day10.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DimaKudosh/word2vec path: /examples/example.rs
extern crate word2vec;
fn main(){
let model = word2vec::wordvectors::WordVector::load_from_binary(
"vectors.bin").expect("Unable to load word vector model");
println!("{:?}", model.cosine("snow", 10));
let positive = vec!["woman", "king"];
le... | code_fim | medium | {
"lang": "rust",
"repo": "DimaKudosh/word2vec",
"path": "/examples/example.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ct("Unable to load word clusters");
println!("{:?}", clusters.get_cluster("belarus"));
println!("{:?}", clusters.get_words_on_cluster(6));
}<|fim_prefix|>// repo: DimaKudosh/word2vec path: /examples/example.rs
extern crate word2vec;
fn main(){
let model = word2vec::wordvectors::WordVector::load_from_... | code_fim | medium | {
"lang": "rust",
"repo": "DimaKudosh/word2vec",
"path": "/examples/example.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut largest = &list[0];
for elem in list {
if elem > largest {
largest = elem;
}
}
largest
}<|fim_prefix|>// repo: waleedsamy/hello_rust path: /src/bin/learn_generics.rs
#![allow(dead_code)]
#[derive(Debug)]
struct Point<T, U> {
x: T,
y: U,
}
impl<... | code_fim | hard | {
"lang": "rust",
"repo": "waleedsamy/hello_rust",
"path": "/src/bin/learn_generics.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: waleedsamy/hello_rust path: /src/bin/learn_generics.rs
#![allow(dead_code)]
#[derive(Debug)]
struct Point<T, U> {
x: T,
y: U,
}
impl<T, U> Point<T, U> {
fn mixup<V, W>(self, other: Point<V, W>) -> Point<T, W> {
Point {
x: self.x,
y: other.y,
}... | code_fim | hard | {
"lang": "rust",
"repo": "waleedsamy/hello_rust",
"path": "/src/bin/learn_generics.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: troygiorshev/rustPractice path: /minigrep/src/main.rs
//! Troy Giorshev
//! From <https://doc.rust-lang.org/book/ch12-00-an-io-project.html>
//! I haven't gone through Ch 14 yet, so my documentation will be ~~a little~~ rough.
//! TODO: Find a (the?) Rust style guide. PEP 8 equivalent?
<... | code_fim | hard | {
"lang": "rust",
"repo": "troygiorshev/rustPractice",
"path": "/minigrep/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // No unwrapping needed here
if let Err(e) = minigrep::run(config) {
eprintln!("Error: {}", e);
process::exit(1);
}
}<|fim_prefix|>// repo: troygiorshev/rustPractice path: /minigrep/src/main.rs
//! Troy Giorshev
//! From <https://doc.rust-lang.org/book/ch12-00-an-io-project.... | code_fim | hard | {
"lang": "rust",
"repo": "troygiorshev/rustPractice",
"path": "/minigrep/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slyedoc/bevy_maze path: /src/player.rs
use bevy::prelude::*;
use crate::cleanup::*;
use crate::AppState;
use crate::maze::MazeSize;
mod config {
use super::*;
pub const COLOR: Color = Color::YELLOW;
pub const WORLD_SCALE: f32 = 600.0;
}
pub struct PlayerPlugin;
impl Plugin for P... | code_fim | hard | {
"lang": "rust",
"repo": "slyedoc/bevy_maze",
"path": "/src/player.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cell_size: f32 = config::WORLD_SCALE / size.x as f32;
commands
.spawn_bundle(SpriteBundle {
sprite: Sprite::new(Vec2::new(cell_size, cell_size)),
transform: Transform::from_xyz(0.0, 0.0, 2.0),
material: materials.player_material.clone(),
... | code_fim | hard | {
"lang": "rust",
"repo": "slyedoc/bevy_maze",
"path": "/src/player.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser!((GROW->Vec<&'static str>) star(or(CAT, DOG)));
#[test]
pub fn parser_makes_parser() {
assert_eq!(DOG.parse_s("dog "), Ok("dog"));
assert_eq!(CAT.parse_s("cat "), Ok("cat"));
assert_eq!(
GROW.parse_s("catdogcatcatno"),
Ok(vec!["cat",... | code_fim | hard | {
"lang": "rust",
"repo": "storyfeet/bogobble",
"path": "/src/macros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: storyfeet/bogobble path: /src/macros.rs
//! The macros primarily exist to make creating zero size parsers easier.
//! Without putting them in macros "&'static str" and "chars" can act as parsers,
//! but they have a size, and when combined they can become bigger.
//! If however all the parsers y... | code_fim | hard | {
"lang": "rust",
"repo": "storyfeet/bogobble",
"path": "/src/macros.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Even if object name is not included in the policy digest ("false" as 3rd parameter)
// Correct name needs to be set or the policy will fail.
context
.policy_duplication_select(policy_session, object_name, parent_name, false)
.unwrap();
context.set... | code_fim | hard | {
"lang": "rust",
"repo": "parallaxsecond/rust-tss-esapi",
"path": "/tss-esapi/tests/integration_tests/context_tests/tpm_commands/duplication_commands_tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_jwt_fixtures() -> Vec<String> {
let valid_token = &JwtPayload {
roles: [
String::from("content.client"),
String::from("therapySession.client"),
String::from("videoChat.client"),
],
uuid: String::from("ecf0fb38-1fe9-11e8-a296-0242ac... | code_fim | medium | {
"lang": "rust",
"repo": "nicolaspearson/speckle",
"path": "/src/jwt.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nicolaspearson/speckle path: /src/jwt.rs
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct JwtPayload {
pub roles: [String; 3],
pub uuid: String,
pub jti: String,
pub platform: String,
}
<|fim_suffix|>pub fn get_jwt_fixtures() -> Vec<Strin... | code_fim | medium | {
"lang": "rust",
"repo": "nicolaspearson/speckle",
"path": "/src/jwt.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Recursing/sunfish_rs path: /src/pieces.rs
use crate::board::{BOARD_SIDE, BOARD_SIZE, PADDING};
pub struct Direction {}
impl Direction {
pub const NORTH: i32 = -(BOARD_SIDE as i32);
pub const EAST: i32 = 1;
pub const SOUTH: i32 = BOARD_SIDE as i32;
pub const WEST: i32 = -1;
}
#... | code_fim | hard | {
"lang": "rust",
"repo": "Recursing/sunfish_rs",
"path": "/src/pieces.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // From stockfish /src/psqt.cpp#L31
let piece_position_value = match self {
Square::MyPawn => &[
0, 0, 0, 0, 0, 0, 0, 0, // Last rank, no pawns
15, 31, 20, 14, 23, 11, 37, 24, //
-1, -3, 15, 26, 1, 10, -7, -9, //
8... | code_fim | hard | {
"lang": "rust",
"repo": "Recursing/sunfish_rs",
"path": "/src/pieces.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn midgame_value(self, position: usize) -> i32 {
debug_assert!(
position >= BOARD_SIDE * PADDING + PADDING
&& position < BOARD_SIZE - BOARD_SIDE * PADDING - PADDING
&& position % BOARD_SIDE >= PADDING
&& position % BOARD_SIDE < BO... | code_fim | hard | {
"lang": "rust",
"repo": "Recursing/sunfish_rs",
"path": "/src/pieces.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cluster = LocalCluster::new(&mut cluster_config, SocketAddrSpace::Unspecified);
let validator_keys: Vec<Arc<Keypair>> = validator_keys
.into_iter()
.map(|(keypair, _)| keypair)
.collect();
(cluster, validator_keys)
}
pub fn farf_dir() -> PathBuf {
std::env::va... | code_fim | hard | {
"lang": "rust",
"repo": "solana-labs/solana",
"path": "/local-cluster/src/integration_tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: solana-labs/solana path: /local-cluster/src/integration_tests.rs
ary will fail if
// a handle to Blockstore is being held somewhere else
.unwrap_or_else(|_| {
Blockstore::open_with_options(
ledger_path,
BlockstoreOptions {
access_type: Acce... | code_fim | hard | {
"lang": "rust",
"repo": "solana-labs/solana",
"path": "/local-cluster/src/integration_tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: solana-labs/solana path: /local-cluster/src/integration_tests.rs
sts` folder.
//!
//! According to the cargo documentation, integration tests are compiled as individual crates.
//!
//! https://doc.rust-lang.org/book/ch11-03-test-organization.html#the-tests-directory
//!
//! Putting shared code... | code_fim | hard | {
"lang": "rust",
"repo": "solana-labs/solana",
"path": "/local-cluster/src/integration_tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lloydmeta/frunk path: /core/src/traits.rs
//! Traits that provide generic functionality for multiple types in frunk
/// An alternative to AsRef that does not force the reference type to be a pointer itself.
///
/// This lets us create implementations for our recursive traits that take the resul... | code_fim | hard | {
"lang": "rust",
"repo": "lloydmeta/frunk",
"path": "/core/src/traits.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
/// Wrapper type around a function for polymorphic maps and folds.
///
/// This is a thin generic wrapper type that is used to differentiate
/// between single-typed generic closures `F` that implements, say, `Fn(i8) -> bool`,
/// and a Poly-typed `F` that implements multiple Function types
/// via the... | code_fim | hard | {
"lang": "rust",
"repo": "lloydmeta/frunk",
"path": "/core/src/traits.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// This is a simple, user-implementable alternative to `Fn`.
///
/// Might not be necessary if/when Fn(Once, Mut) traits are implementable
/// in stable Rust
pub trait Func<Input> {
type Output;
/// Call the `Func`.
///
/// Notice that this does not take a self argument, which in turn me... | code_fim | hard | {
"lang": "rust",
"repo": "lloydmeta/frunk",
"path": "/core/src/traits.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> u
}
}
/// Return the sparse vanishing polynomial.
pub fn vanishing_polynomial(&self) -> crate::fft::SparsePolynomial<F> {
let coeffs = vec![(0, -F::one()), (self.size(), F::one())];
crate::fft::SparsePolynomial::from_coefficients_vec(coeffs)
}
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "sec-bit/zkp-toolkit",
"path": "/math/src/fft/domain.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sec-bit/zkp-toolkit path: /math/src/fft/domain.rs
// The following code is from (scipr-lab's zexe)[https://github.com/scipr-lab/zexe] and thanks for their work
//! This module contains an `EvaluationDomain` abstraction for
//! performing various kinds of polynomial arithmetic on top of
//! the ... | code_fim | hard | {
"lang": "rust",
"repo": "sec-bit/zkp-toolkit",
"path": "/math/src/fft/domain.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[wasm_bindgen(js_namespace = import, js_name = meta)]
static IMPORT_META: ImportMeta;
}
pub fn on_the_fly(code: &str) -> Result<String, JsValue> {
// Generate the import of the bindgen ES module, assuming `--target web`.
let header = format!(
"import init, * as bindgen from '{}';... | code_fim | medium | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/examples/wasm-audio-worklet/src/dependent_module.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustwasm/wasm-bindgen path: /examples/wasm-audio-worklet/src/dependent_module.rs
use js_sys::{Array, JsString};
use wasm_bindgen::prelude::*;
use web_sys::{Blob, BlobPropertyBag, Url};
// This is a not-so-clean approach to get the current bindgen ES module URL
// in Rust. This will fail at run ... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/examples/wasm-audio-worklet/src/dependent_module.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[wasm_bindgen(js_namespace = import, js_name = meta)]
static IMPORT_META: ImportMeta;
}
pub fn on_the_fly(code: &str) -> Result<String, JsValue> {
// Generate the import of the bindgen ES module, assuming `--target web`.
let header = format!(
"import init, * as bindgen from '{}'... | code_fim | medium | {
"lang": "rust",
"repo": "rustwasm/wasm-bindgen",
"path": "/examples/wasm-audio-worklet/src/dependent_module.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_length() {
systest!("(length)" => Error);
systest!("(length '(1) '(2))" => Error);
systest!("(length '(a b c))" => "3");
systest!("(length '(a (b) (c d e)))" => "3");
systest!("(length '())" => "0");
}
#[test]
fn test_lambda() {
systest!("(lambda)" => Error);
s... | code_fim | hard | {
"lang": "rust",
"repo": "jbschlosser/resin",
"path": "/src/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jbschlosser/resin path: /src/tests.rs
use super::*;
#[macro_export]
macro_rules! systest {
($input:expr => Error) => {{
let interp = Interpreter::new();
match interp.evaluate($input) {
Ok(d) => panic!("Expected error, got {}", d),
Err(_) => ()
... | code_fim | hard | {
"lang": "rust",
"repo": "jbschlosser/resin",
"path": "/src/tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: venkatarun95/channel_est path: /src/lib.rs
//! Module for channel estimation for multiple frequencies. We assume the following packet
//! structure, which mirrors the 802.11 standard:
//! <Short Preamble> <Long Training Sequence> [<Data symbols> ...]
//!
//! Short Preamble:
//! - 10 repeats of ... | code_fim | medium | {
"lang": "rust",
"repo": "venkatarun95/channel_est",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use cfo::{correct_cfo, estimate_cfo};
pub use equalization::{equalize_symbol, estimate_subcarrier_equalization};
pub use lts_align::lts_align;
pub use parse_80211::parse_80211_pkt;
pub use pkt_trigger::PktTrigger;<|fim_prefix|>// repo: venkatarun95/channel_est path: /src/lib.rs
//! Module for channel... | code_fim | medium | {
"lang": "rust",
"repo": "venkatarun95/channel_est",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: happysalada/poem path: /poem-openapi/src/validation/max_length.rs
use derive_more::Display;
use crate::{
registry::MetaSchema,
validation::{Validator, ValidatorMeta},
};
#[derive(Display)]
#[display(fmt = "maxLength({})", len)]
pub struct MaxLength {
len: usize,
}
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "happysalada/poem",
"path": "/poem-openapi/src/validation/max_length.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> value.as_ref().len() <= self.len
}
}
impl ValidatorMeta for MaxLength {
fn update_meta(&self, meta: &mut MetaSchema) {
meta.max_length = Some(self.len);
}
}<|fim_prefix|>// repo: happysalada/poem path: /poem-openapi/src/validation/max_length.rs
use derive_more::Display;
use ... | code_fim | hard | {
"lang": "rust",
"repo": "happysalada/poem",
"path": "/poem-openapi/src/validation/max_length.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: plorefice/rv6 path: /rvalloc/src/lib.rs
//! A collection of heap allocators for rv6.
#![no_std]
#![warn(missing_docs)]
#![deny(missing_debug_implementations)]
#![feature(asm)]
// Require explicit unsafe blocks even in unsafe fn
#![feature(unsafe_block_in_unsafe_fn)]
#![deny(unsafe_op_in_unsafe_... | code_fim | hard | {
"lang": "rust",
"repo": "plorefice/rv6",
"path": "/rvalloc/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ptr = match bump.ptr.checked_sub(layout.size()) {
Some(ptr) => ptr,
None => return null_mut(),
};
let ptr = ptr & !(layout.align() - 1);
if ptr < bump.start {
return null_mut();
}
bump.allocated += 1;
bump.pt... | code_fim | hard | {
"lang": "rust",
"repo": "plorefice/rv6",
"path": "/rvalloc/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: penrose/penrose path: /packages/optimizer/src/lib.rs
// typed `call_grad` and `call_stop` functions in JavaScript and then use `wasm-bindgen` to import
// them into Rust here; as far as I know, the `extern "C"` syntax is historical and in this case
// we're not actually doing anything related to... | code_fim | hard | {
"lang": "rust",
"repo": "penrose/penrose",
"path": "/packages/optimizer/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn minimize(
mut f: impl FnMut(&[f64], f64, &mut [f64]) -> f64,
xs0: &[f64],
weight: f64,
lbfgs_info: LbfgsParams,
mut stop: impl FnMut() -> bool,
) -> OptInfo {
// TODO: Do a UO convergence check here? Since the EP check is tied to the render cycle...
log::info!("------------... | code_fim | hard | {
"lang": "rust",
"repo": "penrose/penrose",
"path": "/packages/optimizer/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: penrose/penrose path: /packages/optimizer/src/lib.rs
st tests that, when run,
// generate TypeScript definitions in the `bindings/` directory of this package; that's why the
// `build-decls` script for this package is `cargo test`
#[derive(Clone, Deserialize, Serialize, TS)]
#[ts(export)]
enum ... | code_fim | hard | {
"lang": "rust",
"repo": "penrose/penrose",
"path": "/packages/optimizer/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>IS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//! # InterlockLedger test-utils
//!
//! ## Description
//!
//! **il2-test-utils** is a *Rust* library designed to provide unit-test utilities
//! that can be used by other components of **InterlockLedger** written in *Rust*.
//!
//! See ... | code_fim | hard | {
"lang": "rust",
"repo": "interlockledger/rust-il2-test-utils",
"path": "/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: interlockledger/rust-il2-test-utils path: /src/lib.rs
/*
* BSD 3-Clause License
*
* Copyright (c) 2019-2020, InterlockLedger Network
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following cond... | code_fim | hard | {
"lang": "rust",
"repo": "interlockledger/rust-il2-test-utils",
"path": "/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // run it on the fake cargo cache dir
let cargo_cache = Command::new(bin_path())
.arg("toolchain")
.env("RUSTUP_HOME", "/tmp/this/dir/does/not/exist")
.output();
assert!(cargo_cache.is_ok(), "cargo cache toolchain failed to run");
let cc_output = &cargo_cache.unwrap... | code_fim | medium | {
"lang": "rust",
"repo": "matthiaskrgr/cargo-cache",
"path": "/tests/toolchain.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matthiaskrgr/cargo-cache path: /tests/toolchain.rs
// Copyright 2017-2022 Matthias Krüger. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT ... | code_fim | medium | {
"lang": "rust",
"repo": "matthiaskrgr/cargo-cache",
"path": "/tests/toolchain.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
#[cfg_attr(feature = "offline_tests", ignore)]
fn no_rustup_installed_toolchain() {
// run it on the fake cargo cache dir
let cargo_cache = Command::new(bin_path())
.arg("toolchain")
.env("RUSTUP_HOME", "/tmp/this/dir/does/not/exist")
.output();
assert!(cargo_ca... | code_fim | medium | {
"lang": "rust",
"repo": "matthiaskrgr/cargo-cache",
"path": "/tests/toolchain.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.key.heap_size_of_children() + self.value.heap_size_of_children()
}
}
impl<K, V, S> HeapSizeOf for LinkedHashMap<K, V, S>
where
K: HeapSizeOf + Hash + Eq,
V: HeapSizeOf,
S: BuildHasher,
{
fn heap_size_of_children(&self) -> usize {
unsafe {
let mut size ... | code_fim | medium | {
"lang": "rust",
"repo": "contain-rs/linked-hash-map",
"path": "/src/heapsize.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: contain-rs/linked-hash-map path: /src/heapsize.rs
extern crate heapsize;
use self::heapsize::{heap_size_of, HeapSizeOf};
use std::hash::{BuildHasher, Hash};
use {KeyRef, LinkedHashMap, Node};
<|fim_suffix|> let mut free = self.free;
while !free.is_null() {
... | code_fim | hard | {
"lang": "rust",
"repo": "contain-rs/linked-hash-map",
"path": "/src/heapsize.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !self.head.is_null() {
size += heap_size_of(self.head as *const _ as *const _);
}
let mut free = self.free;
while !free.is_null() {
size += heap_size_of(free as *const _ as *const _);
free = (*free).next
... | code_fim | hard | {
"lang": "rust",
"repo": "contain-rs/linked-hash-map",
"path": "/src/heapsize.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod pipe;
pub use pipe::AppFactory;<|fim_prefix|>// repo: sebglazebrook/infinite-pipe path: /src/lib.rs
#![feature(plugin, custom_derive)]
#![plugin(mockers_macros)]
#![cfg_attr(test, plugin(stainless))]
<|fim_middle|>#[cfg(test)] extern crate mockers;
extern crate rl_sys;
| code_fim | easy | {
"lang": "rust",
"repo": "sebglazebrook/infinite-pipe",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.