text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> variant as u8 != 0
}
}
#[doc = "Reader of field `PAD70INPEN`"]
pub type PAD70INPEN_R = crate::R<bool, PAD70INPEN_A>;
impl PAD70INPEN_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> PAD70INPEN_A {
match self.bits {
false =... | code_fim | hard | {
"lang": "rust",
"repo": "trembel/ambiq-apollo3p-pac",
"path": "/src/gpio/padregr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn geocent_apprnt_ecl_coords() {
let (planet_ecl_point, mut R) = planet::geocent_apprnt_ecl_coords (
&planet::Planet::Venus, 2448976.5
);
let (mut L, mut B) = (planet_ecl_point.long, planet_ecl_point.lat);
L = util::round_upto_digits(angle::limit_to_360(L.to_degrees()), 2)... | code_fim | hard | {
"lang": "rust",
"repo": "albmar/astro-rust",
"path": "/tests/planet.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: albmar/astro-rust path: /tests/planet.rs
/*
Copyright (c) 2015, 2016 Saurav Sachidanand
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including witho... | code_fim | hard | {
"lang": "rust",
"repo": "albmar/astro-rust",
"path": "/tests/planet.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
let (planet_ecl_point, mut R) = planet::geocent_apprnt_ecl_coords (
&planet::Planet::Venus, 2448976.5
);
let (mut L, mut B) = (planet_ecl_point.long, planet_ecl_point.lat);
L = util::round_upto_digits(angle::limit_to_360(L.to_degrees()), 2);
B = util::round_upto_digits(B.to_de... | code_fim | hard | {
"lang": "rust",
"repo": "albmar/astro-rust",
"path": "/tests/planet.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qianxunyuyun2019/TrojanRust path: /src/protocol/trojan/packet.rs
use log::{info, warn};
use std::io::{Result, Error, ErrorKind};
use std::pin::Pin;
use std::task::{Context, Poll};
use std::cmp::min;
use std::convert::TryInto;
use std::borrow::Borrow;
use bytes::{BytesMut, BufMut, Buf};
use tok... | code_fim | hard | {
"lang": "rust",
"repo": "qianxunyuyun2019/TrojanRust",
"path": "/src/protocol/trojan/packet.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// // When we already have all the bytes
// self.buffer.clear();
// self.state = STATE_PAYLOAD;
// ctr += march_size;
// info!("Read trojan udp request header [Len: {}:{:?}:{}]", self.payload_size, &self.a... | code_fim | hard | {
"lang": "rust",
"repo": "qianxunyuyun2019/TrojanRust",
"path": "/src/protocol/trojan/packet.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// info!("Read trojan udp request header [Len: {}:{:?}:{}]", self.payload_size, &self.addr[0..4], self.port);
// }
// STATE_PAYLOAD => {
// let march_size = min(self.payload_size - self.buffer.len(), buf.len() - ctr);
// ... | code_fim | hard | {
"lang": "rust",
"repo": "qianxunyuyun2019/TrojanRust",
"path": "/src/protocol/trojan/packet.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: minatools/marlin path: /dlog/marlin/src/prover.rs
ngProof<G>,
// polynomial evaluations
pub evals: [ProofEvaluations<Fr<G>>; 3],
// prover's scalars
pub sigma2: Fr<G>,
pub sigma3: Fr<G>,
// public part of the witness
pub public: Vec<Fr<G>>,
// The challenges u... | code_fim | hard | {
"lang": "rust",
"repo": "minatools/marlin",
"path": "/dlog/marlin/src/prover.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // prover's scalars
sigma2,
sigma3,
// public part of the witness
public,
prev_challenges,
})
}
// This function computes polynomials for the first sumcheck protocol
// RETURN: prover's H1 & G1 polynomials
... | code_fim | hard | {
"lang": "rust",
"repo": "minatools/marlin",
"path": "/dlog/marlin/src/prover.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let vanish = index.domains.h.evaluate_vanishing_polynomial(beta0) *
&index.domains.h.evaluate_vanishing_polynomial(beta1);
// compute polynomial f3
let f3 = (0..3).map
(
|i|
{
EvaluationDomains::evals_from_coeffs
... | code_fim | hard | {
"lang": "rust",
"repo": "minatools/marlin",
"path": "/dlog/marlin/src/prover.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl MatchInfo {
pub fn merge(&mut self, other: Self) {
assert!(self.index_range.start <= other.index_range.end);
let overlap_len = self.index_range.end - other.index_range.start;
self.line_indices
.extend(other.line_indices.into_iter().skip(overlap_len));
i... | code_fim | medium | {
"lang": "rust",
"repo": "uasi/eru",
"path": "/src/search.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for MatchInfo {
fn default() -> Self {
MatchInfo {
line_indices: Vec::new(),
index_range: 0..0,
}
}
}<|fim_prefix|>// repo: uasi/eru path: /src/search.rs
use std::ops::Range;
use crate::query::Query;
pub struct Request {
pub query: Query,... | code_fim | hard | {
"lang": "rust",
"repo": "uasi/eru",
"path": "/src/search.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uasi/eru path: /src/search.rs
use std::ops::Range;
use crate::query::Query;
pub struct Request {
pub query: Query,
pub start: usize,
}
pub struct Response {
pub query: Query,
pub match_info: MatchInfo,
}
<|fim_suffix|>impl MatchInfo {
pub fn merge(&mut self, other: Self) ... | code_fim | hard | {
"lang": "rust",
"repo": "uasi/eru",
"path": "/src/search.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
// Represents configuration for a strategy.
// Acts as a factory for game strategies, so we can play many rounds
pub trait GameStrategyConfig {
fn initialize(&self, &GameOptions) -> Box<GameStrategy>;
}<|fim_prefix|>// repo: 3tz/ganabi path: /experts/WTFWT/src/strategy.rs
use game::*;
// Traits t... | code_fim | hard | {
"lang": "rust",
"repo": "3tz/ganabi",
"path": "/experts/WTFWT/src/strategy.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 3tz/ganabi path: /experts/WTFWT/src/strategy.rs
use game::*;
// Traits to implement for any valid Hanabi strategy
// Represents the strategy of a given player
pub trait PlayerStrategy {
// A function to decide what to do on the player's turn.
// Given a BorrowedGameView, outputs their ... | code_fim | hard | {
"lang": "rust",
"repo": "3tz/ganabi",
"path": "/experts/WTFWT/src/strategy.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Represents configuration for a strategy.
// Acts as a factory for game strategies, so we can play many rounds
pub trait GameStrategyConfig {
fn initialize(&self, &GameOptions) -> Box<GameStrategy>;
}<|fim_prefix|>// repo: 3tz/ganabi path: /experts/WTFWT/src/strategy.rs
use game::*;
// Traits to i... | code_fim | hard | {
"lang": "rust",
"repo": "3tz/ganabi",
"path": "/experts/WTFWT/src/strategy.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: williele/wigame path: /crates/app/src/query/query.rs
use std::marker::PhantomData;
use crate::World;
use super::{IntoView, View};
#[derive(Debug, Default)]
pub struct Query<V: IntoView> {
_view: PhantomData<V>,
}
impl<V: IntoView> Query<V> {
pub fn new() -> Self {
Query {
... | code_fim | hard | {
"lang": "rust",
"repo": "williele/wigame",
"path": "/crates/app/src/query/query.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for foo in Query::<Write<Foo>>::new().iter(&world) {
foo.0 += 1;
}
for (ent, foo, bar) in Query::<(Entities, Read<Foo>, TryRead<Bar>)>::new().iter(&world) {
println!("{:?} {:?} {:?}", ent, foo, bar);
}
}
}<|fim_prefix|>// repo: williele/wigame ... | code_fim | hard | {
"lang": "rust",
"repo": "williele/wigame",
"path": "/crates/app/src/query/query.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn query() {
let mut world = World::default();
world.spawn().add(Foo(0)).add(Bar(0));
world.spawn().add(Foo(1));
world.spawn().add(Foo(2)).add(Bar(2));
for foo in Query::<Write<Foo>>::new().iter(&world) {
foo.0 += 1;
}
f... | code_fim | hard | {
"lang": "rust",
"repo": "williele/wigame",
"path": "/crates/app/src/query/query.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let card = left.iter_mut().chain(right.iter_mut()).nth(c);
if let Some(card) = card {
if card.destroy {
return Err("Card is to be destroyed".to_string());
}
self.fig... | code_fim | hard | {
"lang": "rust",
"repo": "elmarco/friday",
"path": "/lib/src/friday.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elmarco/friday path: /lib/src/friday.rs
}
(
State::Fighting(c, ref mut used_free, ref mut left, ref mut right, using),
Event::Fight,
) => {
let has_stop = |c: &Card<'a>| {
!c.destroy && c.description.ki... | code_fim | hard | {
"lang": "rust",
"repo": "elmarco/friday",
"path": "/lib/src/friday.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn hazard_level(&self, hazard: &Hazard, step: Step) -> u8 {
match *hazard {
Hazard::Leveled(l) => l[step as usize],
Hazard::Pirate(l) => l,
Hazard::PirateTwiceLife(l) => l,
Hazard::PirateAging => {
let n_aging = if self.level <= 2... | code_fim | hard | {
"lang": "rust",
"repo": "elmarco/friday",
"path": "/lib/src/friday.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: learner-long-life/adventofcode path: /2020/day1/src/main.rs
use std::env;
use std::fs;
use std::collections::HashSet;
use std::collections::HashMap;
fn main() {
let args: Vec<String> = env::args().collect();
println!("{:?}", args);
let filename = &args[1];
println!("in file {}... | code_fim | hard | {
"lang": "rust",
"repo": "learner-long-life/adventofcode",
"path": "/2020/day1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // store whether we've found the bipartite complement in 2020
let mut set : HashSet<i32> = HashSet::new();
// Find a bi-partite product
for i in numbers.iter() {
if set.contains(i) {
// we found the first past of our pair
println!("Found {} and its compleme... | code_fim | hard | {
"lang": "rust",
"repo": "learner-long-life/adventofcode",
"path": "/2020/day1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> },
Option::Some((x, y)) => {
println!("Found triple {} {} {}", x, y, (2020 - x - y));
println!("Their product is {}", x * y * (2020 - x - y));
}
}
}
}<|fim_prefix|>// repo: learner-long-life/adventofcode path: /2020/day1... | code_fim | hard | {
"lang": "rust",
"repo": "learner-long-life/adventofcode",
"path": "/2020/day1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(
vec![Binding {
pg_channel: "pgchannel1".to_string(),
amqp_entity: "exchange1".to_string()
}] == parse_bridge_channels("pgchannel1:exchange1")
);
assert!(
vec![
Binding {
... | code_fim | hard | {
"lang": "rust",
"repo": "speechki-book/pg-amqp-bridge",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: speechki-book/pg-amqp-bridge path: /src/lib.rs
extern crate amqp;
extern crate fallible_iterator;
extern crate postgres;
extern crate r2d2;
extern crate r2d2_postgres;
extern crate uuid;
#[macro_use]
extern crate log;
use amqp::{protocol, AMQPError, Basic, Channel, Session, Table};
use fallible... | code_fim | hard | {
"lang": "rust",
"repo": "speechki-book/pg-amqp-bridge",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn parse_notification(payload: &str) -> (&str, &str) {
let v: Vec<&str> = payload.splitn(2, SEPARATOR).map(|x| x.trim()).collect();
if v.len() > 1 {
(v[0], v[1])
} else {
("", v[0])
}
}
pub fn wait_for_amqp_session(amqp_uri: &str, pg_channel: &str) -> Session {
println... | code_fim | hard | {
"lang": "rust",
"repo": "speechki-book/pg-amqp-bridge",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(pr.is_err());
}
#[test]
fn test_plural_category_all() {
let categories: Vec<&PluralCategory> = PluralCategory::all().collect();
assert_eq!(categories.get(0), Some(&&PluralCategory::Zero));
}<|fim_prefix|>// repo: SahandFarhoodi/icu4x path: /components/plurals/tests/plurals.rs
// Thi... | code_fim | medium | {
"lang": "rust",
"repo": "SahandFarhoodi/icu4x",
"path": "/components/plurals/tests/plurals.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SahandFarhoodi/icu4x path: /components/plurals/tests/plurals.rs
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/master/LICENSE ).
use icu_locid_macros::langid... | code_fim | hard | {
"lang": "rust",
"repo": "SahandFarhoodi/icu4x",
"path": "/components/plurals/tests/plurals.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> post.map(|post| {
let mut ctx = Context::new();
ctx.insert("title", "Articles");
ctx.insert("localisation", "articles");
ctx.insert("post", &post.header);
ctx.insert("content", &post.content);
Template::render("posts/get", &ctx)
})
}<|fim_prefix|>// ... | code_fim | hard | {
"lang": "rust",
"repo": "rloic/rust-portfolio",
"path": "/src/routes/posts.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rloic/rust-portfolio path: /src/routes/posts.rs
use std::path::PathBuf;
use crate::models::HeaderAndContent;
use crate::models::posts::Post;
use rocket_contrib::templates::Template;
use crate::{read_header_and_content, read_header};
use crate::routes::ARTICLES;
use rocket_contrib::templates::ter... | code_fim | hard | {
"lang": "rust",
"repo": "rloic/rust-portfolio",
"path": "/src/routes/posts.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ctx = Context::new();
ctx.insert("title", "Articles");
ctx.insert("localisation", "articles");
ctx.insert("posts", &posts);
Template::render("posts/index", &ctx)
}
#[get("/posts/<slug>")]
pub fn get(slug: String) -> Option<Template> {
let post: Option<HeaderAndContent<Post... | code_fim | hard | {
"lang": "rust",
"repo": "rloic/rust-portfolio",
"path": "/src/routes/posts.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nicklasmoeller/theia path: /src/scenery/hitable.rs
use ::materials::Scatterable;
use ::utils::vec3::Vec3;
use ::utils::ray::Ray;
<|fim_suffix|>pub trait Hitable: Sync {
fn hit(&self, ray: &Ray, t_min: f32, t_max: f32) -> Option<HitRecord>;
}<|fim_middle|>pub struct HitRecord<'a> {
pub t... | code_fim | medium | {
"lang": "rust",
"repo": "nicklasmoeller/theia",
"path": "/src/scenery/hitable.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait Hitable: Sync {
fn hit(&self, ray: &Ray, t_min: f32, t_max: f32) -> Option<HitRecord>;
}<|fim_prefix|>// repo: nicklasmoeller/theia path: /src/scenery/hitable.rs
use ::materials::Scatterable;
use ::utils::vec3::Vec3;
use ::utils::ray::Ray;
<|fim_middle|>pub struct HitRecord<'a> {
pub t... | code_fim | medium | {
"lang": "rust",
"repo": "nicklasmoeller/theia",
"path": "/src/scenery/hitable.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZakaKen/nand2tetris path: /projects/RustJackCompiler/src/SymbolTable.rs
use std::collections::HashMap;
pub struct SymbolTable{
pub class_table: HashMap<String, (String, String, u16)>,
pub sub_table: HashMap<String, (String, String, u16)>,
pub current_symbol: (String, String, u16),
... | code_fim | hard | {
"lang": "rust",
"repo": "ZakaKen/nand2tetris",
"path": "/projects/RustJackCompiler/src/SymbolTable.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn segmentOf(&self) -> String{
match &self.current_symbol.0.clone()[..]{
"static" => {"static".to_string()}
"field" => {"this".to_string()}
"arg" => {"argument".to_string()}
"var" =>{"local".to_string()}
_ => {panic!("undefined kind of segment")}
}
}
pub fn coun... | code_fim | hard | {
"lang": "rust",
"repo": "ZakaKen/nand2tetris",
"path": "/projects/RustJackCompiler/src/SymbolTable.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn indexOf(&self) -> u16{
return self.current_symbol.2.clone()
}
pub fn segmentOf(&self) -> String{
match &self.current_symbol.0.clone()[..]{
"static" => {"static".to_string()}
"field" => {"this".to_string()}
"arg" => {"argument".to_string()}
"var" =>{"local".to_stri... | code_fim | hard | {
"lang": "rust",
"repo": "ZakaKen/nand2tetris",
"path": "/projects/RustJackCompiler/src/SymbolTable.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MocaCDev/Learning-Rust path: /getting_better.rs
pub mod info
{
pub trait Info
{
fn new(name: &'static str, age: u8) -> Self;
fn is_of_age(&self) -> bool;
fn print_all(&self);
}
#[derive(Debug)]
pub struct MyInfo
{
pub name: &'static str,
... | code_fim | hard | {
"lang": "rust",
"repo": "MocaCDev/Learning-Rust",
"path": "/getting_better.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn is_of_age(&self) -> bool
{
if self.age >= 21
{
return true;
}
return false
}
fn print_all(&self)
{
println!("{:?}", self);
}
}
}
use info::Info;
#[allow(unused_variables)]
#... | code_fim | hard | {
"lang": "rust",
"repo": "MocaCDev/Learning-Rust",
"path": "/getting_better.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: infinityb/yscloud path: /boss/bencode/src/value.rs
use serde::{de, ser};
use serde_bytes::ByteBuf;
use std::collections::BTreeMap;
use std::fmt;
use crate::BinStr;
#[derive(PartialEq, Eq, Clone)]
pub enum Value {
Integer(i64),
UInteger(u64),
Bytes(Vec<u8>),
Array(Vec<Value>),
... | code_fim | hard | {
"lang": "rust",
"repo": "infinityb/yscloud",
"path": "/boss/bencode/src/value.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
D: de::Deserializer<'de>,
{
struct ValueVisitor;
impl<'de> de::Visitor<'de> for ValueVisitor {
type Value = Value;
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "a bencode value-like")
}
... | code_fim | hard | {
"lang": "rust",
"repo": "infinityb/yscloud",
"path": "/boss/bencode/src/value.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pattern = pattern.replace(".", "\\.").replace("*", ".*");
let regex = regex::Regex::new(pattern.as_str()).unwrap();
if !regex.is_match(path.to_string_lossy().as_ref()) {
return false;
}
true
}
use error::{Error, ErrorKind};
type Errors = Vec<Error>;
fn validate_dir(dir: Dir, target: &... | code_fim | hard | {
"lang": "rust",
"repo": "AliBasicCoder/fs-pro-rust",
"path": "/src/shape.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>use error::{Error, ErrorKind};
type Errors = Vec<Error>;
fn validate_dir(dir: Dir, target: &'static ShapeSchemaStatic<'static>) -> Errors {
// TODO implement __rest
let mut errors: Errors = vec![];
if !dir.exists() {
errors.push(Error::new_from_kind(ErrorKind::NotFound).set_path(dir.path.clone... | code_fim | hard | {
"lang": "rust",
"repo": "AliBasicCoder/fs-pro-rust",
"path": "/src/shape.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AliBasicCoder/fs-pro-rust path: /src/shape.rs
#![allow(dead_code)]
use crate::error;
use crate::{dir::Dir, file::File};
use std::ffi::OsString;
use std::path::{Path, PathBuf};
#[derive(PartialEq)]
#[allow(missing_docs)]
pub enum ShapeItemStatic<'a> {
File(&'a str, &'a str),
DirectoryPattern... | code_fim | hard | {
"lang": "rust",
"repo": "AliBasicCoder/fs-pro-rust",
"path": "/src/shape.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fooker/shiplift path: /examples/volumes.rs
use shiplift::Docker;
#[tokio::main]
async fn main() {
let docker = Docker::new();
let volumes = docker.volumes();
match volumes.list().await {
Ok<|fim_suffix|>#?}", v)
}
}
Err(e) => eprintln!("Error: {}... | code_fim | medium | {
"lang": "rust",
"repo": "fooker/shiplift",
"path": "/examples/volumes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#?}", v)
}
}
Err(e) => eprintln!("Error: {}", e),
}
}<|fim_prefix|>// repo: fooker/shiplift path: /examples/volumes.rs
use shiplift::Docker;
#[tokio::main]
async fn main() {
let docker = Docker::new<|fim_middle|>();
let volumes = docker.volumes();
match volum... | code_fim | medium | {
"lang": "rust",
"repo": "fooker/shiplift",
"path": "/examples/volumes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>(volumes) => {
for v in volumes {
println!("volume -> {:#?}", v)
}
}
Err(e) => eprintln!("Error: {}", e),
}
}<|fim_prefix|>// repo: fooker/shiplift path: /examples/volumes.rs
use shiplift::Docker;
#[tokio::main]
async fn main() {
let docker... | code_fim | medium | {
"lang": "rust",
"repo": "fooker/shiplift",
"path": "/examples/volumes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jagill/rust-wkt path: /src/tokenizer.rs
use crate::char_class::CharClass;
use crate::parse_error::ParseResult;
pub struct Tokenizer<'s> {
text: &'s str,
index: usize,
}
#[derive(Debug, PartialEq)]
pub struct Token<'s> {
pub index: usize,
pub char_class: CharClass,
pub value... | code_fim | hard | {
"lang": "rust",
"repo": "jagill/rust-wkt",
"path": "/src/tokenizer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_non_whitespace() {
let mut tokens = Tokenizer::new(" X Y () ");
assert_token_value(tokens.next_non_whitespace(), CharClass::Character, "X");
assert_token_value(tokens.next_non_whitespace(), CharClass::Character, "Y");
assert_token_value(tokens.n... | code_fim | hard | {
"lang": "rust",
"repo": "jagill/rust-wkt",
"path": "/src/tokenizer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Goganoid/rplayer path: /src/file_manager.rs
use std::path::{PathBuf, Path};
use glob::glob;
use std::cell::{RefCell};
use rand::seq::SliceRandom;
use mp3_metadata::MP3Metadata;
pub struct FileManager{
pub file_paths: Vec<PathBuf>,
rng:rand::rngs::ThreadRng,
indexes:Vec<usize>,
c... | code_fim | hard | {
"lang": "rust",
"repo": "Goganoid/rplayer",
"path": "/src/file_manager.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
result
}
fn get_index(&self,index:usize) -> usize{
self.indexes[index]
}
pub fn get_current(&self) -> PathBuf{
self.file_paths[self.get_index(*self.cur.try_borrow().unwrap())].clone()
}
pub fn prev(&self) -> Option<PathBuf>{
let mut result... | code_fim | hard | {
"lang": "rust",
"repo": "Goganoid/rplayer",
"path": "/src/file_manager.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>32;
pub const LicenseKeyNotFound: LicenseProtectionStatus = 1i32;
pub const LicenseKeyUnprotected: LicenseProtectionStatus = 2i32;
pub const LicenseKeyCorrupted: LicenseProtectionStatus = 3i32;
pub const LicenseKeyAlreadyExists: LicenseProtectionStatus = 4i32;<|fim_prefix|>// repo: Corallus-Caninus/window... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/deps/sys/src/Windows/Win32/Security/LicenseProtection/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /crates/deps/sys/src/Windows/Win32/Security/LicenseProtection/mod.rs
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {
#[cfg(feature = "Win32_Foundat... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/deps/sys/src/Windows/Win32/Security/LicenseProtection/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct CircuitMembers {
pub node_id: String,
pub endpoints: Vec<String>,
pub public_key: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct CircuitService {
pub service_id: String,
... | code_fim | hard | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/libsplinter/src/admin/client/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cargill/splinter path: /libsplinter/src/admin/client/mod.rs
// Copyright 2018-2022 Cargill Incorporated
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// h... | code_fim | hard | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/libsplinter/src/admin/client/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct VoteRecord {
pub public_key: String,
pub vote: String,
pub voter_node_id: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProposalSlice {
pub proposal_type: String,
pub circui... | code_fim | hard | {
"lang": "rust",
"repo": "Cargill/splinter",
"path": "/libsplinter/src/admin/client/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let count_rows = records.count_rows();
let count_cols = records.count_columns();
for pos in entity.iter(count_rows, count_cols) {
let is_valid_pos = pos.0 < count_rows && pos.1 < count_cols;
if !is_valid_pos {
continue;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "zhiburt/tabled",
"path": "/tabled/src/settings/format/format_positioned.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for pos in entity.iter(count_rows, count_cols) {
let is_valid_pos = pos.0 < count_rows && pos.1 < count_cols;
if !is_valid_pos {
continue;
}
let content = records.get_text(pos);
let content = (self.0)(content, pos);
... | code_fim | medium | {
"lang": "rust",
"repo": "zhiburt/tabled",
"path": "/tabled/src/settings/format/format_positioned.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhiburt/tabled path: /tabled/src/settings/format/format_positioned.rs
use crate::{
grid::config::Entity,
grid::records::{ExactRecords, PeekableRecords, Records, RecordsMut},
settings::{CellOption, TableOption},
};
/// [`FormatContentPositioned`] is like a [`FormatContent`] an abstra... | code_fim | hard | {
"lang": "rust",
"repo": "zhiburt/tabled",
"path": "/tabled/src/settings/format/format_positioned.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialicons/image/icon_hdr_off.rs
pub struct IconHdrOff {
props: crate::Props,
}
impl yew::Component for IconHdrOff {
type Properties = crate::Props;
type Message = ();
fn create(props: Self::Properties, _: yew::prelude::ComponentLink<... | code_fim | hard | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialicons/image/icon_hdr_off.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: c-goldschmidt/AoC_2015 path: /src/days/day23.rs
use crate::days::day::{New, Parts};
use crate::days::utils::LineMatch;
use regex::{Regex, Captures};
#[derive(PartialEq,Copy,Clone)]
enum Action { HLF, TPL, INC, JMP, JIE, JIO }
#[derive(PartialEq,Copy,Clone)]
enum Register { A, B }
pub struct D... | code_fim | hard | {
"lang": "rust",
"repo": "c-goldschmidt/AoC_2015",
"path": "/src/days/day23.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.reg_b;
}
}
impl LineMatch for StateMachine {
fn get_regex(&self) -> Regex {
return Regex::new(r"^(?P<instruction>\w{3}) (?:(?P<register>[ab])(?:$|, ))?(?:\+?(?P<value>-?\d+))?$").unwrap();
}
fn add_match(&mut self, cap: Captures) {
let instruction = ma... | code_fim | hard | {
"lang": "rust",
"repo": "c-goldschmidt/AoC_2015",
"path": "/src/days/day23.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YushiOMOTE/baremetal-yubaba path: /src/time.rs
pub fn rdtsc() -> u64 {
unsafe {
core::arch::x86_64::_mm_lfence();
core::arch::x86_64:<|fim_suffix|>start = rdtsc();
while rdtsc() - start < time {}
}<|fim_middle|>:_rdtsc()
}
}
pub fn sleep(time: u64) {
let | code_fim | easy | {
"lang": "rust",
"repo": "YushiOMOTE/baremetal-yubaba",
"path": "/src/time.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>:_rdtsc()
}
}
pub fn sleep(time: u64) {
let start = rdtsc();
while rdtsc() - start < time {}
}<|fim_prefix|>// repo: YushiOMOTE/baremetal-yubaba path: /src/time.rs
pub fn rdtsc() -> u64 {
unsafe {
core::ar<|fim_middle|>ch::x86_64::_mm_lfence();
core::arch::x86_64: | code_fim | easy | {
"lang": "rust",
"repo": "YushiOMOTE/baremetal-yubaba",
"path": "/src/time.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: krircc/kayrx path: /src/krse/io/driver/linux/mod.rs
#![allow(bare_trait_objects, deprecated, unknown_lints)]
#![deny(missing_docs, missing_debug_implementations)]
//! A fast, low-level IO library for Rust focusing on non-blocking APIs, event
//! notification, and other useful utilities for buil... | code_fim | hard | {
"lang": "rust",
"repo": "krircc/kayrx",
"path": "/src/krse/io/driver/linux/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>! // Create a poll instance
//! let poll = Poll::new().unwrap();
//!
//! // Start listening for incoming connections
//! poll.register(&server, SERVER, Ready::readable(),
//! PollOpt::edge()).unwrap();
//!
//! // Setup the client socket
//! let sock = TcpStream::connect(&addr).unwrap();
//!
... | code_fim | hard | {
"lang": "rust",
"repo": "krircc/kayrx",
"path": "/src/krse/io/driver/linux/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn no_bids_no_winner() {
let mut auction = AuctionState::new();
let _user_id1 = auction.create_new_user();
let item_id = auction.create_new_item(199.0);
let winner = auction.end_auction(item_id);
assert!(winner.is_none());
}
#[test]
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "kurnev/auction",
"path": "/tests/auction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn several_bids_for_several_different_items() {
let mut auction = AuctionState::new();
let user_id1 = auction.create_new_user();
let user_id2 = auction.create_new_user();
let user_id3 = auction.create_new_user();
let item_id1 = auction.create_new_ite... | code_fim | hard | {
"lang": "rust",
"repo": "kurnev/auction",
"path": "/tests/auction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kurnev/auction path: /tests/auction.rs
extern crate auction;
#[cfg(test)]
mod tests {
use auction::{auction::AuctionState, bid::BidResultCode};
#[test]
fn simple_5_buyers_auction_with_a_winner() {
let mut auction = AuctionState::new();
let user_id1 = auction.create... | code_fim | hard | {
"lang": "rust",
"repo": "kurnev/auction",
"path": "/tests/auction.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[async_trait]
impl<OuterState, InnerState> FromRequestParts<OuterState> for State<InnerState>
where
InnerState: FromRef<OuterState>,
OuterState: Send + Sync,
{
type Rejection = Infallible;
async fn from_request_parts(
_parts: &mut Parts,
... | code_fim | medium | {
"lang": "rust",
"repo": "tokio-rs/axum",
"path": "/axum-core/src/ext_traits/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tokio-rs/axum path: /axum-core/src/ext_traits/mod.rs
pub(crate) mod request;
pub(crate) mod request_parts;
#[cfg(test)]
mod tests {
use std::convert::Infallible;
use crate::extract::{FromRef, FromRequestParts};
use async_trait::async_trait;
use http::request::Parts;
#[deri... | code_fim | hard | {
"lang": "rust",
"repo": "tokio-rs/axum",
"path": "/axum-core/src/ext_traits/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn from_request_parts(
_parts: &mut Parts,
state: &S,
) -> Result<Self, Self::Rejection> {
Ok(Self(String::from_ref(state)))
}
}
}<|fim_prefix|>// repo: tokio-rs/axum path: /axum-core/src/ext_traits/mod.rs
pub(crate) mod request;
pub(c... | code_fim | hard | {
"lang": "rust",
"repo": "tokio-rs/axum",
"path": "/axum-core/src/ext_traits/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if r.start_date > r.end_date {
Err(anyhow!(
"Start date after end date for entry: {}, {}, {}",
r.id,
r.start_date,
r.end_date
))
} else {
Ok(())
}
}
pub fn validate_all_records(records: &[Entry]) -> Vec<anyhow::Error> {
... | code_fim | hard | {
"lang": "rust",
"repo": "jamesmcm/rust_ses_example",
"path": "/src/csv_serde.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jamesmcm/rust_ses_example path: /src/csv_serde.rs
use anyhow::{anyhow, Result};
use chrono::naive::NaiveDateTime;
use serde::{Deserialize, Serialize};
use std::io::Cursor;
#[derive(Debug, Deserialize, Serialize, PartialEq)]
pub struct Entry {
#[serde(alias = "ID")]
pub id: u32,
#[se... | code_fim | medium | {
"lang": "rust",
"repo": "jamesmcm/rust_ses_example",
"path": "/src/csv_serde.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Now `data` and `other_data` point to different values.
assert_eq!(*data, 8);
assert_eq!(*other_data, 12);
//ReftCell
let value = Rc::new(RefCell::new(5));
let a = Rc::new(Rc::clone(&value));
let b = Rc::clone(&a);
let c = Rc::clone(&a);
*value.borrow_mut() += 1... | code_fim | hard | {
"lang": "rust",
"repo": "msaf1980/rust-lang-book",
"path": "/15-smart-ptr/rc/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: msaf1980/rust-lang-book path: /15-smart-ptr/rc/src/main.rs
enum List {
Cons(i32, Rc<List>),
Nil,
}
use List::{Cons, Nil};
use std::rc::Rc;
use std::cell::RefCell;
fn main() {
let a = Rc::new(Cons(5, Rc::new(Cons(10, Rc::new(Nil)))));
println!("count after creating a = {}", Rc::... | code_fim | medium | {
"lang": "rust",
"repo": "msaf1980/rust-lang-book",
"path": "/15-smart-ptr/rc/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn colors_are_equal() {
let c1 = Color::new(0.5, 0.25, 0.1);
let c2 = Color::new(0.5, 0.25, 0.1);
assert_eq!(c1, c2);
}
#[test]
fn color_plus_color() {
let c1 = Color::new(0.9, 0.6, 0.75);
let c2 = Color::new(0.7, 0.1, 0.25);
let... | code_fim | hard | {
"lang": "rust",
"repo": "xeinherjar/rayray",
"path": "/src/color.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xeinherjar/rayray path: /src/color.rs
pub use std::f64::{EPSILON};
use std::ops;
#[derive(Debug, Copy, Clone)]
pub struct Color {
pub r: f64,
pub g: f64,
pub b: f64,
}
impl Color {
pub fn new(r: f64, g: f64, b: f64) -> Color {
Color{r: r, g: g, b: b}
}
}
impl Parti... | code_fim | hard | {
"lang": "rust",
"repo": "xeinherjar/rayray",
"path": "/src/color.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ops::Mul<f64> for Color {
type Output = Color;
fn mul(self, f: f64) -> Color {
Color::new(self.r * f, self.g * f, self.b * f)
}
}
impl ops::Mul<Color> for Color {
type Output = Color;
fn mul(self, c: Color) -> Color {
Color::new(self.r * c.r, self.g * c.g, self.b ... | code_fim | hard | {
"lang": "rust",
"repo": "xeinherjar/rayray",
"path": "/src/color.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vadixidav/evomush path: /src/cell/mod.rs
mod brain;
use zoom::*;
use nalgebra as na;
use rand::Rng;
use gapush::simple::{SimpleInstruction, PlainOp};
use auxillary::area_box;
use zoom::particle;
use std::cell;
const INIT_ENERGY: usize = 1 << 20;
const SIZE_TO_ENERGY_RATIO: f64 = 0.05;
const CO... | code_fim | hard | {
"lang": "rust",
"repo": "vadixidav/evomush",
"path": "/src/cell/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn interact_repel(&self, other: &Self, newton: f64) {
use nalgebra::Norm;
let distance_squared = area_box().wrap_delta(self.particle.position - other.particle.position).norm_squared();
if self.closest_distance_squared.get().map(|d| d > distance_squared).unwrap_or(true) {
... | code_fim | hard | {
"lang": "rust",
"repo": "vadixidav/evomush",
"path": "/src/cell/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: UrkelLabs/rsd path: /primitives/src/transaction/transaction.rs
use crate::{Input, Output};
use cryptoxide::blake2b::Blake2b;
use cryptoxide::digest::Digest;
use encodings::hex::{FromHex, FromHexError, ToHex};
use extended_primitives::{Buffer, Hash, VarInt};
use handshake_encoding::{Decodable, De... | code_fim | hard | {
"lang": "rust",
"repo": "UrkelLabs/rsd",
"path": "/primitives/src/transaction/transaction.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let hex = "000000000189b8fefcbc040b03b3de29e1d7836716379e0282dfcd8d8be693431e15ba1bc301000000ffffffff0200000000000000000014f6448adf6a19ef63cbf7a00404b6b3c4bad059960203208323ce31d4f62e2c2a89e1aaffd4ed31cef82b3a462bfd4a9007b1a78b9ae49b04000000000b63616e6e61627574746572e7203193000000000014fce9ecbb201... | code_fim | hard | {
"lang": "rust",
"repo": "UrkelLabs/rsd",
"path": "/primitives/src/transaction/transaction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let e = [fls, tru, tru, fls];
let r: [u32; 4] = transmute(_mm_cmpge_ps(a, b));
assert_eq!(r, e);
}
test_mm_cmpge_ps();
#[target_feature(enable = "sse")]
unsafe fn test_mm_cmpneq_ps() {
let a = _mm_setr_ps(10.0, 50.0, 1.0, NAN);
let b = _mm_setr_ps(1... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/miri",
"path": "/tests/pass/intrinsics-x86-sse.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/miri path: /tests/pass/intrinsics-x86-sse.rs
b1), 2.0, 3.0, 4.0));
assert_eq!(rb, eb);
let rc: [u32; 4] = transmute(_mm_cmpnge_ss(a, c));
let ec: [u32; 4] = transmute(_mm_setr_ps(transmute(c1), 2.0, 3.0, 4.0));
assert_eq!(rc, ec);
let rd: [u32;... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/miri",
"path": "/tests/pass/intrinsics-x86-sse.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/miri path: /tests/pass/intrinsics-x86-sse.rs
rt_ps(a);
let e = _mm_setr_ps(2.0, 3.6055512, 4.0, 10.0);
assert_eq_m128(r, e);
}
test_mm_sqrt_ps();
#[target_feature(enable = "sse")]
unsafe fn test_mm_rcp_ss() {
let a = _mm_setr_ps(4.0, 13.0, 16.0,... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/miri",
"path": "/tests/pass/intrinsics-x86-sse.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FnOnce<()> for C {
type Output = String;
extern "rust-call" fn call_once(self, (): ()) -> Self::Output {
self.0
}
}
struct D(Box<String>);
impl FnOnce<()> for D {
type Output = String;
extern "rust-call" fn call_once(self, (): ()) -> Self::Output {
*self.0
}
... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass-valgrind/unsized-locals/by-value-trait-objects-rust-call.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FnOnce<()> for D {
type Output = String;
extern "rust-call" fn call_once(self, (): ()) -> Self::Output {
*self.0
}
}
fn main() {
let x = *(Box::new(A) as Box<dyn FnOnce<(), Output = String>>);
assert_eq!(x.call_once(()), format!("hello"));
let x = *(Box::new(B(42)) a... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/run-pass-valgrind/unsized-locals/by-value-trait-objects-rust-call.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0.get_any_value(i).map(|av| av.into_time())
}
unsafe fn get_any_value_unchecked(&self, i: usize) -> AnyValue<'_> {
self.0.get_any_value_unchecked(i).into_time()
}
fn cast(&self, dtype: &DataType) -> PolarsResult<Series> {
match dtype {
DataType::Du... | code_fim | medium | {
"lang": "rust",
"repo": "pola-rs/polars",
"path": "/crates/polars-core/src/chunked_array/logical/time.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pola-rs/polars path: /crates/polars-core/src/chunked_array/logical/time.rs
use super::*;
use crate::prelude::*;
pub type TimeChunked = Logical<TimeType, Int64Type>;
impl From<Int64Chunked> for TimeChunked {
fn from(ca: Int64Chunked) -> Self {
TimeChunked::new_logical(ca)
}
}
i... | code_fim | hard | {
"lang": "rust",
"repo": "pola-rs/polars",
"path": "/crates/polars-core/src/chunked_array/logical/time.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod i2c;
pub mod serial;<|fim_prefix|>// repo: loyd/hodok path: /src/ifaces/mod.rs
pub use self::i2c::I2C;
pub use self::serial::Serial;
<|fim_middle|>
macro_rules! check_io(
($cond:expr) =>
(if !$cond { return Err(io::Error::last_os_error()); })
);
| code_fim | medium | {
"lang": "rust",
"repo": "loyd/hodok",
"path": "/src/ifaces/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: loyd/hodok path: /src/ifaces/mod.rs
pub use self::i2c::I2C;
pub use self::serial::Serial;
<|fim_suffix|>pub mod i2c;
pub mod serial;<|fim_middle|>macro_rules! check_io(
($cond:expr) =>
(if !$cond { return Err(io::Error::last_os_error()); })
);
| code_fim | medium | {
"lang": "rust",
"repo": "loyd/hodok",
"path": "/src/ifaces/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adamnemecek/rust-autograd path: /src/ops/gradient_descent_ops/sgd.rs
use ndarray_ext::NdArray;
use op;
use tensor::Tensor;
struct SGDOp {
pub lr: f32,
}
impl ::op::Op for SGDOp {
fn name(&self) -> &str {
<|fim_suffix|> fn compute(&self, mut ctx: ::runtime::OpComputeContext) -> op::C... | code_fim | medium | {
"lang": "rust",
"repo": "adamnemecek/rust-autograd",
"path": "/src/ops/gradient_descent_ops/sgd.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> SGD {
pub fn compute_updates<T: AsRef<Tensor>>(
&mut self,
params: &[&'a Tensor],
grads: &[T],
) -> Vec<Tensor> {
params
.into_iter()
.zip(grads)
.map(|(param, grad)| {
Tensor::builder()
... | code_fim | medium | {
"lang": "rust",
"repo": "adamnemecek/rust-autograd",
"path": "/src/ops/gradient_descent_ops/sgd.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> vec![None]
}
}
/// Vanilla SGD optimizer
pub struct SGD {
pub lr: f32,
}
impl<'a> SGD {
pub fn compute_updates<T: AsRef<Tensor>>(
&mut self,
params: &[&'a Tensor],
grads: &[T],
) -> Vec<Tensor> {
params
.into_iter()
.zip(gra... | code_fim | hard | {
"lang": "rust",
"repo": "adamnemecek/rust-autograd",
"path": "/src/ops/gradient_descent_ops/sgd.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> cursor.expect(
TokenKind::Keyword((Keyword::Await, false)),
"Await expression parsing",
interner,
)?;
let expr = UnaryExpression::new(None, self.allow_yield, true).parse(cursor, interner)?;
Ok(expr.into())
}
}<|fim_prefix|>// repo: bo... | code_fim | hard | {
"lang": "rust",
"repo": "boa-dev/boa",
"path": "/boa_parser/src/parser/expression/await_expr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: boa-dev/boa path: /boa_parser/src/parser/expression/await_expr.rs
//! Await expression parsing.
//!
//! More information:
//! - [MDN documentation][mdn]
//! - [ECMAScript specification][spec]
//!
//! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await
//! [... | code_fim | hard | {
"lang": "rust",
"repo": "boa-dev/boa",
"path": "/boa_parser/src/parser/expression/await_expr.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn new(engine: &mut Engine) -> Level {
let mut scene = Self::load_level(engine);
let EngineInterfaceMut { scenes, sound_context, resource_manager, .. } = engine.interface_mut();
let mut actors = ActorContainer::new();
let mut weapons = WeaponContainer::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "dmvoiper/rusty-shooter",
"path": "/src/level.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_actors(&self) -> &ActorContainer {
&self.actors
}
pub fn get_actors_mut(&mut self) -> &mut ActorContainer {
&mut self.actors
}
pub fn get_weapons(&self) -> &WeaponContainer {
&self.weapons
}
fn update_bots(&mut self, engine: &mut Engine) {
... | code_fim | hard | {
"lang": "rust",
"repo": "dmvoiper/rusty-shooter",
"path": "/src/level.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.