text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> const EXAMPLE: &str = r#".#.#...|#.
.....#|##|
.|..|...#.
..|#.....#
#.#|||#|#|
...#.||...
.|....|...
||...#|.#|
|.||||..|.
...#.|..|."#;
const ONE_MINUTE: &str = r#".......##.
......|###
.|..|...#.
..|#||...#
..##||.|#|
...#||||..
||...|||..
|||||.||.|
||||||||||
....||..|.
"#;
const TEN_MI... | code_fim | hard | {
"lang": "rust",
"repo": "plaflamme/advent-2018",
"path": "/src/puzzle18/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some((int, num, den))
}
#[test]
fn test_simplify() {
assert_eq!(simplify(14, 3), Some((4, 2, 3)));
assert_eq!(simplify(3, 8), Some((0, 3, 8)));
assert_eq!(simplify(4, 8), Some((0, 1, 2)));
assert_eq!(simplify(4, 3), Some((1, 1, 3)));
assert_eq!(simplify(5, 1), Some((5, 0, 1)));
... | code_fim | medium | {
"lang": "rust",
"repo": "OsProgramadores/op-desafios",
"path": "/desafio-08/leovano/rust/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for line in file.lines() {
let frac = line
.expect("LineFail")
.split('/')
.map(|it| it.parse::<i64>())
.collect::<Result<Vec<i64>, _>>()
.expect("ParseFail");
let num = *frac.get(0).expect("Linha vazia");
let den = *f... | code_fim | hard | {
"lang": "rust",
"repo": "OsProgramadores/op-desafios",
"path": "/desafio-08/leovano/rust/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: OsProgramadores/op-desafios path: /desafio-08/leovano/rust/main.rs
use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn gcd(a: i64, b: i64) -> i64 {
if a == 0 {
b
} else {
gcd(b % a, a)
}
}
fn simplify(num: i64, den: i64) -> Option<(i64, i64, i64)>... | code_fim | medium | {
"lang": "rust",
"repo": "OsProgramadores/op-desafios",
"path": "/desafio-08/leovano/rust/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn load_transcript(
&self,
transcript: &IDkgTranscript,
) -> Result<Vec<IDkgComplaint>, IDkgTranscriptLoadError> {
let logger = new_logger!(&self.logger;
crypto.trait_name => "IDkgTranscriptGenerator",
crypto.method_name => "load_transcript",
... | code_fim | hard | {
"lang": "rust",
"repo": "0x0402/rosetta-node",
"path": "/crypto/src/sign/canister_threshold_sig/dkg.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0x0402/rosetta-node path: /crypto/src/sign/canister_threshold_sig/dkg.rs
use crate::sign::log_err;
use crate::CryptoComponentFatClient;
use ic_crypto_internal_csp::CryptoServiceProvider;
use ic_interfaces::crypto::IDkgTranscriptGenerator;
use ic_logger::{debug, new_logger};
use ic_types::crypto:... | code_fim | hard | {
"lang": "rust",
"repo": "0x0402/rosetta-node",
"path": "/crypto/src/sign/canister_threshold_sig/dkg.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn open_transcript(
&self,
transcript_id: IDkgTranscriptId,
complaint: &IDkgComplaint,
) -> Result<IDkgOpening, IDkgTranscriptOpeningError> {
let logger = new_logger!(&self.logger;
crypto.trait_name => "IDkgTranscriptGenerator",
crypto.method... | code_fim | hard | {
"lang": "rust",
"repo": "0x0402/rosetta-node",
"path": "/crypto/src/sign/canister_threshold_sig/dkg.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: beru/ruffle path: /core/src/avm1/globals.rs
Context, Value};
use crate::backend::navigator::NavigationMethod;
use enumset::EnumSet;
use gc_arena::MutationContext;
use rand::Rng;
use std::f64;
mod array;
pub(crate) mod boolean;
pub(crate) mod button;
mod color;
pub(crate) mod display_object;
mod... | code_fim | hard | {
"lang": "rust",
"repo": "beru/ruffle",
"path": "/core/src/avm1/globals.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let shared_object_proto = shared_object::create_proto(gc_context, object_proto, function_proto);
let shared_obj = shared_object::create_shared_object_object(
gc_context,
Some(shared_object_proto),
Some(function_proto),
);
globals.define_value(
gc_context,
... | code_fim | hard | {
"lang": "rust",
"repo": "beru/ruffle",
"path": "/core/src/avm1/globals.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: beru/ruffle path: /core/src/avm1/globals.rs
ult<ReturnValue<'gc>, Error<'gc>> {
if let Some(val) = args.get(0) {
Ok(val.coerce_to_f64(avm, action_context)?.is_nan().into())
} else {
Ok(true.into())
}
}
pub fn get_infinity<'gc>(
avm: &mut Avm1<'gc>,
_action_co... | code_fim | hard | {
"lang": "rust",
"repo": "beru/ruffle",
"path": "/core/src/avm1/globals.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yijie37/DaQiao path: /bridge/parity-ethereum/ethcore/types/src/errors/engine_error.rs
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as... | code_fim | hard | {
"lang": "rust",
"repo": "yijie37/DaQiao",
"path": "/bridge/parity-ethereum/ethcore/types/src/errors/engine_error.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> use self::EngineError::*;
let msg = match *self {
CliqueMissingCheckpoint(ref hash) => format!("Missing checkpoint block: {}", hash),
CliqueMissingVanity => format!("Extra data is missing vanity data"),
CliqueMissingSignature => format!("Extra data is missing signature"),
CliqueCheckpointI... | code_fim | hard | {
"lang": "rust",
"repo": "yijie37/DaQiao",
"path": "/bridge/parity-ethereum/ethcore/types/src/errors/engine_error.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn create(props: Self::Properties, link: ComponentLink<Self>) -> Self {
error!("JoiningGame: created with {:?}", props);
link.send_message(Msg::JoinRound);
let game_ws_mgr_callback = link.callback(Msg::GameWsResponse);
JoiningGame {
link,
game_s... | code_fim | hard | {
"lang": "rust",
"repo": "totorigolo/cards-client-rs",
"path": "/src/pages/joining_game.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: totorigolo/cards-client-rs path: /src/pages/joining_game.rs
use anyhow::Result;
use log::*;
use std::time::Duration;
use yew::prelude::*;
use yew::services::interval::IntervalService;
use yew::services::Task;
use yew_router::agent::{RouteAgentDispatcher, RouteRequest};
use yew_router::route::Rou... | code_fim | hard | {
"lang": "rust",
"repo": "totorigolo/cards-client-rs",
"path": "/src/pages/joining_game.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> (JoinStep::JoinedGameWithWebSocket { player_id, .. }, Msg::SuccessfullyJoined) => {
let route: Route = AppRoute::PlayGame {
game_id: self.game_id.clone(),
player_id,
}
.into();
RouteAgentDis... | code_fim | hard | {
"lang": "rust",
"repo": "totorigolo/cards-client-rs",
"path": "/src/pages/joining_game.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(creep) = job.get_creep() {
let r = self.inner.heal(&creep);
match r {
ReturnCode::Ok => {
if job
.get_creep()
.map(|c| c.hits() == c.hits_max())
.unwrap_o... | code_fim | hard | {
"lang": "rust",
"repo": "Cogitri/screeps",
"path": "/src/creeps/tower.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cogitri/screeps path: /src/creeps/tower.rs
use super::{Job, JobOffer};
use crate::constants;
use log::*;
use screeps::{prelude::*, Attackable, ResourceType, ReturnCode, StructureTower};
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("Couldn't attack: `{0:?}`")]
A... | code_fim | hard | {
"lang": "rust",
"repo": "Cogitri/screeps",
"path": "/src/creeps/tower.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johansmitsnl/oxfeed path: /front/src/components/popover.rs
#[derive(Clone, PartialEq, Eq, yew::Properties)]
pub(crate) struct Properties {
#[prop_or_default]
pub title: Option<String>,
pub text: String,
pub position: String,
}
pub(crate) struct Component {
props: Properties,... | code_fim | hard | {
"lang": "rust",
"repo": "johansmitsnl/oxfeed",
"path": "/front/src/components/popover.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> yew::html! {
<div class=("popover", position_class)>
<div class="arrow"></div>
{
if let Some(title) = &self.props.title {
yew::html! {
<div class="popover-header">{ title }</div>
... | code_fim | hard | {
"lang": "rust",
"repo": "johansmitsnl/oxfeed",
"path": "/front/src/components/popover.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>e<Varchar>,
created -> Timestamp,
updated_at -> Timestamp,
}
}<|fim_prefix|>// repo: archetect/archetype-rust-service-actix-diesel-workspace path: /contents/{{ artifact-id }}/{{ artifact-id }}-persistence/src/schema.rs
table! {
{{ prefix_name }} (id) {
<|fim_middle|> id -> ... | code_fim | easy | {
"lang": "rust",
"repo": "archetect/archetype-rust-service-actix-diesel-workspace",
"path": "/contents/{{ artifact-id }}/{{ artifact-id }}-persistence/src/schema.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cbrewster/advent_of_code_2019 path: /day11/src/main.rs
mod computer;
use computer::{parse_program, Computer};
use std::collections::HashMap;
#[derive(Debug, Clone, Copy)]
enum Direction {
Up,
Down,
Left,
Right,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum Color {
Wh... | code_fim | hard | {
"lang": "rust",
"repo": "cbrewster/advent_of_code_2019",
"path": "/day11/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut computer = Computer::new(program);
let mut painted_tiles = HashMap::new();
let mut position = (0, 0);
let mut direction = Direction::Up;
computer.push_input(0);
while let Some(paint) = computer.execute() {
let color = match paint {
0 => Color::Black,
... | code_fim | hard | {
"lang": "rust",
"repo": "cbrewster/advent_of_code_2019",
"path": "/day11/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
let inc_paths = [
"./mdbtools/include",
"/usr/local/Cellar/glib/2.46.2/include/glib-2.0"
];
compile_c_lib(&inc_paths,
&src_files,
"libmdb.a");
println!("cargo:rustc-link-search=native={}", out_dir);
println!("cargo:rustc-link-lib=static=mdb... | code_fim | hard | {
"lang": "rust",
"repo": "gumpyoung/rust-mdbtools",
"path": "/mdbtools/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> compile_c_lib(&inc_paths,
&src_files,
"libmdb.a");
println!("cargo:rustc-link-search=native={}", out_dir);
println!("cargo:rustc-link-lib=static=mdb");
}<|fim_prefix|>// repo: gumpyoung/rust-mdbtools path: /mdbtools/build.rs
extern crate gcc;
extern crate pkg_config;
use std:... | code_fim | hard | {
"lang": "rust",
"repo": "gumpyoung/rust-mdbtools",
"path": "/mdbtools/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gumpyoung/rust-mdbtools path: /mdbtools/build.rs
extern crate gcc;
extern crate pkg_config;
use std::env;
fn compile_c_lib(
inc_paths : &[&str],
src_files : &[&str],
output : &str){
let mut cfg = gcc::Config::new();
for inc_path in inc_paths {
cfg.include(inc_path);
}
for src... | code_fim | hard | {
"lang": "rust",
"repo": "gumpyoung/rust-mdbtools",
"path": "/mdbtools/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> *array.readwrite().get_mut(0).unwrap() = Timedelta::<units::Minutes>::from(5);
let np = py
.eval("__import__('numpy')", None, None)
.unwrap()
.downcast::<PyModule>()
.unwrap();
py_run!(py, array np, "asse... | code_fim | hard | {
"lang": "rust",
"repo": "PyO3/rust-numpy",
"path": "/src/datetime.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PyO3/rust-numpy path: /src/datetime.rs
//! Support datetimes and timedeltas
//!
//! This module provides wrappers for NumPy's [`datetime64`][scalars-datetime64] and [`timedelta64`][scalars-timedelta64] types
//! which are used for time keeping with with an emphasis on scientific applications.
//... | code_fim | hard | {
"lang": "rust",
"repo": "PyO3/rust-numpy",
"path": "/src/datetime.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let dtype = match dtypes.get_or_insert_with(Default::default).entry(unit) {
Entry::Occupied(entry) => entry.into_mut(),
Entry::Vacant(entry) => {
let dtype = PyArrayDescr::new_from_npy_type(py, self.npy_type);
// SAFETY: `self.npy_type` is e... | code_fim | hard | {
"lang": "rust",
"repo": "PyO3/rust-numpy",
"path": "/src/datetime.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kuwana-kb/ddd-in-rust path: /chapter09_factory/src/infrastructure/datastore/mock_context.rs
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use anyhow::Result;
use common::MyError;
use crate::domain::{Name, User, UserFactory, UserId, UserRepository};
<|fim_suffix|>impl UserReposit... | code_fim | hard | {
"lang": "rust",
"repo": "kuwana-kb/ddd-in-rust",
"path": "/chapter09_factory/src/infrastructure/datastore/mock_context.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug, Default)]
pub struct MockContext {
db: Arc<Mutex<HashMap<UserId, User>>>,
counter: Arc<Mutex<i32>>,
}
// MockにおけるUserFactoryの実装
// MockContext内のカウンターを利用して採番する
impl UserFactory for MockContext {
fn create(&self, name: Name) -> Result<User> {
let counter = self.co... | code_fim | medium | {
"lang": "rust",
"repo": "kuwana-kb/ddd-in-rust",
"path": "/chapter09_factory/src/infrastructure/datastore/mock_context.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// MockにおけるUserFactoryの実装
// MockContext内のカウンターを利用して採番する
impl UserFactory for MockContext {
fn create(&self, name: Name) -> Result<User> {
let counter = self.counter.clone();
let mut counter = counter
.try_lock()
.map_err(|_| MyError::internal_server_error("fail... | code_fim | medium | {
"lang": "rust",
"repo": "kuwana-kb/ddd-in-rust",
"path": "/chapter09_factory/src/infrastructure/datastore/mock_context.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Darkspear7/gl-rs path: /src/gl_generator/lib.rs
// Copyright 2013-2014 The gl-rs developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use t... | code_fim | hard | {
"lang": "rust",
"repo": "Darkspear7/gl-rs",
"path": "/src/gl_generator/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tts = drop_trailing_comma(tts);
// Iterate through the comma separated
for tts in tts.split(is_comma) {
let mut it = tts.iter();
let field = match it.next() {
Some(&TtToken(_, token::Ident(ref field, _))) => field.as_str(),
tt => {
l... | code_fim | hard | {
"lang": "rust",
"repo": "Darkspear7/gl-rs",
"path": "/src/gl_generator/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod backend;
pub mod loader;
pub mod layer;
pub mod network;<|fim_prefix|>// repo: ttakamura/binary-nn-rust path: /src/lib.rs
#[macro_use]
extern crate serde_derive;
<|fim_middle|>pub mod sandbox {
pub fn add(x: i32, y: i32) -> i32 {
x + y
}
}
| code_fim | medium | {
"lang": "rust",
"repo": "ttakamura/binary-nn-rust",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ttakamura/binary-nn-rust path: /src/lib.rs
#[macro_use]
extern crate serde_derive;
<|fim_suffix|>pub mod backend;
pub mod loader;
pub mod layer;
pub mod network;<|fim_middle|>pub mod sandbox {
pub fn add(x: i32, y: i32) -> i32 {
x + y
}
}
| code_fim | medium | {
"lang": "rust",
"repo": "ttakamura/binary-nn-rust",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skillzaa/animation path: /tests/auto.rs
use bilzaa2dcounter::Animation;
use bilzaa2dattributes::AttributesEnum;
//use #[should_panic] with the test --if to check errors
fn test_a(a:Animation,time_ms:u128,answer:u128){
match a.animate(time_ms) {
Some(x)=> assert_eq!(x as u128,answer... | code_fim | hard | {
"lang": "rust",
"repo": "skillzaa/animation",
"path": "/tests/auto.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a:Animation = get_a(10,20,200,100);
test_a(a, 0, 200);
}
#[test]
#[should_panic]
fn reverse_four(){ // its zero--start time--will ret none
let a:Animation = get_a(10,20,200,100);
test_a(a, 10000, 200);
}
#[test]
fn reverse_five(){//50%
let a:Animation = get_a(10,50,200,100);
test_a(a, 3... | code_fim | hard | {
"lang": "rust",
"repo": "skillzaa/animation",
"path": "/tests/auto.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let a:Animation = get_a(10,20,0,100);
test_a(a, 15000, 50);
}
#[test]
fn aaa(){
let a:Animation = get_a(10,20,100,200);
test_a(a, 15000, 150);
}
#[test]
fn reverse_one(){
let a:Animation = get_a(10,20,200,100);
test_a(a, 15000, 150);
}
#[test]
fn reverse_two(){
let a:Animation = get_a(10,... | code_fim | hard | {
"lang": "rust",
"repo": "skillzaa/animation",
"path": "/tests/auto.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Simpler version of `Rand`, without support for alternative distributions.
///
/// TODO: decide which version of `Rand` to keep. If this one, rename struct to
/// `Rand` and function to `rand`.
///
/// # Example
/// ```rust
/// use rand::distributions::SimpleRand;
///
/// let mut rng = rand::thread_... | code_fim | hard | {
"lang": "rust",
"repo": "nixpulvis/rand",
"path": "/src/distributions/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// the perf improvement (25-50%) is definitely worth the extra code
// size from force-inlining.
#[cfg(feature="std")]
#[inline(always)]
fn ziggurat<R: Rng+?Sized, P, Z>(
rng: &mut R,
symmetric: bool,
x_tab: ziggurat_tables::ZigTable,
f_tab: ziggurat_tables:... | code_fim | hard | {
"lang": "rust",
"repo": "nixpulvis/rand",
"path": "/src/distributions/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nixpulvis/rand path: /src/distributions/mod.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.... | code_fim | hard | {
"lang": "rust",
"repo": "nixpulvis/rand",
"path": "/src/distributions/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: johnward/rust_cas path: /cas/grpc_service/cas_server.rs
// Copyright 2020-2021 Nathan (Blaise) Bruer. All rights reserved.
use std::collections::HashMap;
use std::convert::TryFrom;
use std::convert::TryInto;
use std::io::Cursor;
use std::pin::Pin;
use std::sync::Arc;
use std::time::Instant;
u... | code_fim | hard | {
"lang": "rust",
"repo": "johnward/rust_cas",
"path": "/cas/grpc_service/cas_server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tonic::async_trait]
impl ContentAddressableStorage for CasServer {
async fn find_missing_blobs(
&self,
grpc_request: Request<FindMissingBlobsRequest>,
) -> Result<Response<FindMissingBlobsResponse>, Status> {
log::info!("\x1b[0;31mfind_missing_blobs Req\x1b[0m: {:?}", grp... | code_fim | hard | {
"lang": "rust",
"repo": "johnward/rust_cas",
"path": "/cas/grpc_service/cas_server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn batch_read_blobs(
&self,
grpc_request: Request<BatchReadBlobsRequest>,
) -> Result<Response<BatchReadBlobsResponse>, Status> {
log::info!("\x1b[0;31mbatch_read_blobs Req\x1b[0m: {:?}", grpc_request.get_ref());
let now = Instant::now();
let resp = se... | code_fim | hard | {
"lang": "rust",
"repo": "johnward/rust_cas",
"path": "/cas/grpc_service/cas_server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // **NOTE**
// q does not take ownership of w from that "push_str"
// we know this because we can still print w after we push it into q
let mut q = String::from("lo");
let w = "l";
q.push_str(w);
println!("w is {}", w);
println!("q: {}", q);
// **Concatenation with the... | code_fim | medium | {
"lang": "rust",
"repo": "aj03794/rust-docs",
"path": "/strings/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aj03794/rust-docs path: /strings/src/main.rs
fn main() {
// creating a new, empty string
let s = String::new();
// this is same as line 9?
// This is a &static str type
let data = "initial contents";
println!("data: {}", data);
let data_two = String::from("initial co... | code_fim | hard | {
"lang": "rust",
"repo": "aj03794/rust-docs",
"path": "/strings/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kevinw/crayon path: /src/video/assets/mesh_loader.rs
use bincode;
use std::io::Read;
use std::sync::Arc;
use errors::*;
use super::super::VideoSystemShared;
use super::mesh::*;
pub const MAGIC: [u8; 8] = [
'V' as u8, 'M' as u8, 'S' as u8, 'H' as u8, ' ' as u8, 0, 0, 1,
];
pub struct Mesh... | code_fim | hard | {
"lang": "rust",
"repo": "kevinw/crayon",
"path": "/src/video/assets/mesh_loader.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // MAGIC: [u8; 8]
if &buf[0..8] != &MAGIC[..] {
bail!("[MeshLoader] MAGIC number not match.");
}
let params: MeshParams = bincode::deserialize_from(&mut file)?;
let data = bincode::deserialize_from(&mut file)?;
info!(
"[MeshLoader] ... | code_fim | medium | {
"lang": "rust",
"repo": "kevinw/crayon",
"path": "/src/video/assets/mesh_loader.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let params: MeshParams = bincode::deserialize_from(&mut file)?;
let data = bincode::deserialize_from(&mut file)?;
info!(
"[MeshLoader] loads {:?}. (Verts: {}, Indxes: {})",
handle, params.num_verts, params.num_idxes
);
self.video.update_mes... | code_fim | hard | {
"lang": "rust",
"repo": "kevinw/crayon",
"path": "/src/video/assets/mesh_loader.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TateKennington/rust-tracer path: /src/scene.rs
pub mod camera;
use crate::geometry::hittable::{HitResult, Hittable};
use crate::geometry::ray::Ray;
use crate::geometry::Geometry;
use crate::material::MaterialKind;
pub struct Scene {
pub objects: Vec<Object>,
}
pub struct Object {
geom... | code_fim | hard | {
"lang": "rust",
"repo": "TateKennington/rust-tracer",
"path": "/src/scene.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut hit: Option<HitResult> = None;
for object in self.objects.iter() {
let best_t = if let Some(best_hit) = &hit {
best_hit.t
} else {
max_t
};
if let Some(new_hit) = object.hit(ray, min_t, best_t) {
... | code_fim | hard | {
"lang": "rust",
"repo": "TateKennington/rust-tracer",
"path": "/src/scene.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !has_cooldown_active(unit) {
return false;
}
if let Some(weapon) = weapon_to_target(unit, target) {
let range = weapon.max_range();
let own_area = unit.collision_rect();
bw::rect_distance(&own_area, &tar... | code_fim | hard | {
"lang": "rust",
"repo": "neivv/aise",
"path": "/src/in_combat.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: neivv/aise path: /src/in_combat.rs
use bw_dat::{Game, Unit, WeaponId};
use fxhash::FxHashMap;
use crate::bw;
use crate::unit::{self, HashableUnit};
/// Since in_combat checks "is this unit being targeted by anyone", it requires going through
/// all units in game, so cache and sort the targeti... | code_fim | hard | {
"lang": "rust",
"repo": "neivv/aise",
"path": "/src/in_combat.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Cons(_, item) => Some(item),
Nil => None,
}
}
}
pub fn main() {
println!("\n--- ref cycles can cause memo leaks ---");
// creating a ref-counted list containing 5
let a = Rc::new(Cons(5, RefCell::new(Rc::new(Nil))));
println!("a i... | code_fim | hard | {
"lang": "rust",
"repo": "wulymammoth/rust-book",
"path": "/pointers/src/ref_cycles_mem_leak.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wulymammoth/rust-book path: /pointers/src/ref_cycles_mem_leak.rs
/// reference cycles can leak memory
///
/// LINK: https://doc.rust-lang.org/book/ch15-06-reference-cycles.html
///
/// - this happens when we accidentally create memory that is never cleaned up
/// - NOT one of Rust's guarantees a... | code_fim | medium | {
"lang": "rust",
"repo": "wulymammoth/rust-book",
"path": "/pointers/src/ref_cycles_mem_leak.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AntonGepting/tmux-interface-rs path: /src/commands/clients_and_sessions/lock_session_tests.rs
#[test]
fn lock_session() {
use crate::LockSession;
use std::borrow::Cow;
// Lock all clients attached to `target-session`
// # Manual
//
// tmux ^1.1:
// ```text
// loc... | code_fim | hard | {
"lang": "rust",
"repo": "AntonGepting/tmux-interface-rs",
"path": "/src/commands/clients_and_sessions/lock_session_tests.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(not(feature = "cmd_alias"))]
let cmd = "lock-session";
#[cfg(feature = "cmd_alias")]
let cmd = "locks";
let mut s = Vec::new();
s.push(cmd);
#[cfg(feature = "tmux_1_1")]
s.extend_from_slice(&["-t", "1"]);
let s: Vec<Cow<str>> = s.into_iter().map(|a| a.into()).col... | code_fim | hard | {
"lang": "rust",
"repo": "AntonGepting/tmux-interface-rs",
"path": "/src/commands/clients_and_sessions/lock_session_tests.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_halfword(&mut self, addr: u32, val: u32) {
self.set_byte(addr, util::get_byte(val, 0) as u8);
self.set_byte(addr + 1, util::get_byte(val, 8) as u8);
}
pub fn set_word(&mut self, addr: u32, val: u32) {
self.set_byte(addr, util::get_byte(val, 0) as u8);
... | code_fim | hard | {
"lang": "rust",
"repo": "felixzhuologist/wasm-gba",
"path": "/src/mem/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// given an absolute address into memory, convert it to a reference to
/// one of the memory segments and an index into that segment
pub fn get_loc(&self, addr: u32) -> Option<(&[u8], usize)> {
// TODO: use addr / 0x01000000 instead of a match statement?
let result: (&[u8], u3... | code_fim | hard | {
"lang": "rust",
"repo": "felixzhuologist/wasm-gba",
"path": "/src/mem/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: felixzhuologist/wasm-gba path: /src/mem/mod.rs
mod addrs;
mod framebuffer;
mod palette;
pub mod io;
pub mod oam;
use std;
use util;
use mem::io::addrs::*;
use mem::io::dma::TimingMode;
use self::addrs::*;
pub struct Memory {
pub raw: RawMemory,
// these are parsed versions of raw data ... | code_fim | hard | {
"lang": "rust",
"repo": "felixzhuologist/wasm-gba",
"path": "/src/mem/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: samanpa/babel path: /src/utils/union_find.rs
//A simple disjoint set datastructure without path compression.
use std::marker::PhantomData;
pub trait DisjointSetKey {
fn make(index: u32) -> Self;
fn index(&self) -> u32;
}
impl DisjointSetKey for u32 {
fn make(index: u32) -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "samanpa/babel",
"path": "/src/utils/union_find.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut set = DisjointSet::<u32, char>::with_capacity(10);
let node1 = set.add('1');
let node2 = set.add('2');
let node3 = set.add('3');
let node4 = set.add('4');
let node5 = set.add('5');
let node6 = set.add('6');
assert_eq!(*set.find(node1... | code_fim | hard | {
"lang": "rust",
"repo": "samanpa/babel",
"path": "/src/utils/union_find.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone)]
pub struct SetAttributesOperation {
pub perm: Option<FileMode>,
pub uid: Option<u32>,
pub gid: Option<u32>,
pub size: Option<u64>,
pub atim: Option<Timespec>,
pub mtim: Option<Timespec>,
}
#[derive(Clone)]
pub struct WriteOperation {
pub offset: i64,
pub d... | code_fim | medium | {
"lang": "rust",
"repo": "m4tx/offs",
"path": "/liboffs/src/modify_op.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m4tx/offs path: /liboffs/src/modify_op.rs
use crate::store::{FileDev, FileMode, FileType};
use crate::timespec::Timespec;
#[derive(Clone)]
pub struct CreateFileOperation {
pub name: String,
pub file_type: FileType,
pub perm: FileMode,
pub dev: FileDev,
}
#[derive(Clone)]
pub st... | code_fim | hard | {
"lang": "rust",
"repo": "m4tx/offs",
"path": "/liboffs/src/modify_op.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kvakvs/ErlangRT path: /lib-erlangrt/src/beam/opcodes/binary/bs_get_binary.rs
use crate::{
beam::disp_result::DispatchResult,
defs::BitSize,
emulator::{heap::THeapOwner, process::Process, runtime_ctx::*},
fail::RtResult,
term::{
boxed::binary::{match_state::BinaryMatchState, BinaryS... | code_fim | hard | {
"lang": "rust",
"repo": "kvakvs/ErlangRT",
"path": "/lib-erlangrt/src/beam/opcodes/binary/bs_get_binary.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl OpcodeBsGetBinary2 {
#[inline]
#[allow(clippy::too_many_arguments)]
unsafe fn bs_get_binary2_7(
runtime_ctx: &mut RuntimeContext,
proc: &mut Process,
_fail: Term,
match_state: *mut BinaryMatchState,
live: usize,
size: usize,
unit: usize,
_flags: Term,
dst: Te... | code_fim | hard | {
"lang": "rust",
"repo": "kvakvs/ErlangRT",
"path": "/lib-erlangrt/src/beam/opcodes/binary/bs_get_binary.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn counter_iterator_next() {
dbg!("counter_iterator::counter_iterator_next");
let mut counter = Counter1::new(7);
loop {
// counter implements Iterator trait, so it has next()
match counter.next() {
Some(i) => println!("{}", i),
None => break,
... | code_fim | hard | {
"lang": "rust",
"repo": "kimsk/try-rust",
"path": "/pascal/iterators-in-rust/src/counter_iterator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kimsk/try-rust path: /pascal/iterators-in-rust/src/counter_iterator.rs
// http://gradebot.org/doc/ipur/iterator.html
#[derive(PartialEq, Debug)]
pub struct Counter1 {
max: i32,
// `count` tracks the state of this iterator.
count: i32,
}
impl Counter1 {
pub fn new(max: i32) -> Co... | code_fim | medium | {
"lang": "rust",
"repo": "kimsk/try-rust",
"path": "/pascal/iterators-in-rust/src/counter_iterator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn counter_iterator() {
dbg!("counter_iterator::counter_iterator");
let counter = Counter1::new(7);
// counter implements Iterator trait
// Rust automatically implements IntoIterator for any type that implements Iterator.
// impl<I> IntoIterator for I where I: Iterator
// so it... | code_fim | hard | {
"lang": "rust",
"repo": "kimsk/try-rust",
"path": "/pascal/iterators-in-rust/src/counter_iterator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Universe {
pub fn new() -> Self {
Universe { page: Page::Zero }
}
pub fn populate(&self, seed: u64) {
let mut rng = SmallRng::seed_from_u64(seed);
for _ in 0..(WIDTH * HEIGHT / 8) {
let x = rng.gen_range(0..WIDTH) as usize;
let y = rng.gen_... | code_fim | hard | {
"lang": "rust",
"repo": "mogenson/gba-game-of-life",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn step(&mut self) {
let (page, frame) = if self.page == Page::Zero {
(Page::One, true)
} else {
(Page::Zero, false)
};
for x in 0..WIDTH {
for y in 0..HEIGHT {
Mode5::write(page, x as usize, y as usize, self.next... | code_fim | hard | {
"lang": "rust",
"repo": "mogenson/gba-game-of-life",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mogenson/gba-game-of-life path: /src/lib.rs
#![no_std]
#![feature(exclusive_range_pattern)]
use gba::{
io::display::DISPCNT,
vram::bitmap::{Mode5, Page},
Color,
};
use rand::{
rngs::SmallRng,
{Rng, SeedableRng},
};
const ALIVE: Color = Color::from_rgb(0, 31, 0);
const DEAD:... | code_fim | hard | {
"lang": "rust",
"repo": "mogenson/gba-game-of-life",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shadowmint/rust-pup path: /crates/pup-core/src/manifest.rs
use crate::logger::get_logger;
use crate::utils::path;
use crate::utils::path::{exists, join};
use crate::{PupError, PupErrorType};
use base_logging::Level;
use serde_yaml;
use std::collections::HashMap;
use std::error::Error;
use std::f... | code_fim | hard | {
"lang": "rust",
"repo": "shadowmint/rust-pup",
"path": "/crates/pup-core/src/manifest.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Check and load all paths in the manifest
pub fn validate(&mut self, path: &Path) -> Result<(), PupError> {
let mut logger = get_logger();
for version in self.versions.iter_mut() {
let mut version_path = join(path, join("versions", &version.version));
if ... | code_fim | hard | {
"lang": "rust",
"repo": "shadowmint/rust-pup",
"path": "/crates/pup-core/src/manifest.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_nested_bags_quantity(bags: &[Bag], map: &HashMap<&str, Vec<Bag>>) -> u64 {
let mut total = 0;
for bag in bags {
let inside_bags = get_bags_inside_bag(&bag.color, map);
let local_quantity =
bag.quantity + bag.quantity * get_nested_bags_quantity(&inside_bags, m... | code_fim | hard | {
"lang": "rust",
"repo": "patrickelectric/advent-of-code-2020",
"path": "/src/7/bags.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: patrickelectric/advent-of-code-2020 path: /src/7/bags.rs
use regex::Regex;
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct Bag {
pub color: String,
pub quantity: u64,
}
pub fn get_map_of_bags(rules: &str) -> HashMap<&str, Vec<Bag>> {
let mut map: HashMap<&str, Vec... | code_fim | hard | {
"lang": "rust",
"repo": "patrickelectric/advent-of-code-2020",
"path": "/src/7/bags.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'s, T> PrevTrackerSystem<T>
where
T: Clone + Send + Sync + 'static,
{
/// Returns a String representing this system's name.
pub fn system_name(&self) -> String {
format!("{}<{}>", any::type_name::<Self>(), self.resource_name)
}
}
impl<'s, T> System<'s> for PrevTrackerSystem<T... | code_fim | hard | {
"lang": "rust",
"repo": "azriel91/autexousious",
"path": "/crate/tracker/src/system/prev_tracker_system.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: azriel91/autexousious path: /crate/tracker/src/system/prev_tracker_system.rs
use std::{any, marker::PhantomData};
use amethyst::{
ecs::{LazyUpdate, Read, ReadExpect, System, World, WriteExpect},
shred::{ResourceId, SystemData},
};
use derivative::Derivative;
use derive_new::new;
use cr... | code_fim | hard | {
"lang": "rust",
"repo": "azriel91/autexousious",
"path": "/crate/tracker/src/system/prev_tracker_system.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
PrevTrackerSystemData {
resource,
resource_prev,
lazy_update,
}: Self::SystemData,
) {
if let Some(resource) = resource.as_ref() {
let resource_prev_next = Prev::new((*resource).clone());
if let Some... | code_fim | hard | {
"lang": "rust",
"repo": "azriel91/autexousious",
"path": "/crate/tracker/src/system/prev_tracker_system.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.insert(key.into(), val.into());
}
}<|fim_prefix|>// repo: eagletmt/rusoto path: /src/param.rs
//! Parameters for talking to query-based AWS services.
//!
//! Key-value pairs for AWS query requests.
//!
//! Supports optional parameters for calling SQS and ETS.
use std::collections::BTree... | code_fim | medium | {
"lang": "rust",
"repo": "eagletmt/rusoto",
"path": "/src/param.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eagletmt/rusoto path: /src/param.rs
//! Parameters for talking to query-based AWS services.
//!
//! Key-value pairs for AWS query requests.
//!
//! Supports optional parameters for calling SQS and ETS.
use std::collections::BTreeMap;
pub type Params = BTreeMap<String, String>;
<|fim_suffix|>im... | code_fim | medium | {
"lang": "rust",
"repo": "eagletmt/rusoto",
"path": "/src/param.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: parallaxsecond/parsec-interface-rs path: /src/operations/psa_asymmetric_encrypt.rs
// Copyright 2020 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0
//! # PsaAsymmetricEncrypt operation
//!
//! Encrypt a short message with a public key.
use super::psa_key_attributes::... | code_fim | hard | {
"lang": "rust",
"repo": "parallaxsecond/parsec-interface-rs",
"path": "/src/operations/psa_asymmetric_encrypt.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
(Operation {
key_name: String::from("some key"),
alg: AsymmetricEncryption::RsaOaep {
hash_alg: Hash::Sha256,
},
plaintext: vec![0xff, 32].into(),
salt: None,
})
... | code_fim | hard | {
"lang": "rust",
"repo": "parallaxsecond/parsec-interface-rs",
"path": "/src/operations/psa_asymmetric_encrypt.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mattwparas/playlist-assist path: /src/optimizer.rs
trait Optimizable {
type Penalty: PartialOrd;
fn penalty(&self) -> Self::Penalty;
fn perform_swap(&mut self, i: usize, j: usize);
fn perform_swaps(&mut self) -> Self::Penalty;
}
#[derive(Clone, Copy, Debug)]
struct TrackWrapp... | code_fim | hard | {
"lang": "rust",
"repo": "mattwparas/playlist-assist",
"path": "/src/optimizer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Final output: {:?}", energy_dist.input);
assert_eq!(final_penalty, 0.0);
}
#[test]
fn test_basic_should_min() {
let input = vec![
TrackWrapper::new(0, 0.0),
TrackWrapper::new(0, 0.8),
TrackWrapper::new(0, 0.9),
... | code_fim | hard | {
"lang": "rust",
"repo": "mattwparas/playlist-assist",
"path": "/src/optimizer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Optimizable for EnergyDist {
type Penalty = f64;
fn penalty(&self) -> Self::Penalty {
self.input
.iter()
.zip(self.func.iter())
.map(|x| (x.0.energy - x.1).abs())
.sum()
}
fn perform_swap(&mut self, i: usize, j: usize) {
... | code_fim | hard | {
"lang": "rust",
"repo": "mattwparas/playlist-assist",
"path": "/src/optimizer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
pub fn has_gpos_mark(&self) -> bool {
unsafe {
ffi::hb_ot_shape_plan_has_gpos_mark(self.plan.as_ptr())
}
}
}<|fim_prefix|>// repo: AlbertoGP/rustybuzz path: /src/ot/shape_plan.rs
use std::os::raw::c_void;
use std::ptr::NonNull;
use crate::{ffi, ot, Scrip... | code_fim | medium | {
"lang": "rust",
"repo": "AlbertoGP/rustybuzz",
"path": "/src/ot/shape_plan.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlbertoGP/rustybuzz path: /src/ot/shape_plan.rs
use std::os::raw::c_void;
use std::ptr::NonNull;
use crate::{ffi, ot, Script};
pub struct ShapePlan {
#[allow(dead_code)]
plan: NonNull<ffi::hb_ot_shape_plan_t>,
pub ot_map: ot::Map,
}
<|fim_suffix|> #[inline]
pub fn script(&s... | code_fim | hard | {
"lang": "rust",
"repo": "AlbertoGP/rustybuzz",
"path": "/src/ot/shape_plan.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn brand(&self) -> &str {
&self.brand
}
}
/// The relationships of the vehicules (cf: https://github.com/chargeprice/chargeprice-api-docs/blob/master/api/v1/vehicles/index.md)
#[derive(Debug, Deserialize)]
pub struct VehiculeRelationships {
manufacturer: InnerData<EntityRef>,
}
im... | code_fim | medium | {
"lang": "rust",
"repo": "yageek/chargeprice-rs",
"path": "/chargeprice/src/api/vehicule.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yageek/chargeprice-rs path: /chargeprice/src/api/vehicule.rs
use serde::Deserialize;
use super::{
jsonapi::{DocumentData, EntityRef, InnerData},
plug::Plug,
Entity,
};
<|fim_suffix|>impl VehiculeRelationships {
pub fn manufacturer_id(&self) -> &str {
&self.manufacturer.... | code_fim | hard | {
"lang": "rust",
"repo": "yageek/chargeprice-rs",
"path": "/chargeprice/src/api/vehicule.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: komori-n/ProjectEuler-rs path: /src/bin/problem_004.rs
use itertools::iproduct;
use project_euler_rs::number_misc::is_palindromic;
<|fim_suffix|> let ans = iproduct!(100u64..1000u64, 100u64..1000u64)
.filter(|(x, y)| x <= y)
.map(|(x, y)| x * y)
.filter(|z| is_palindromic(*z))
.max()
... | code_fim | easy | {
"lang": "rust",
"repo": "komori-n/ProjectEuler-rs",
"path": "/src/bin/problem_004.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ans = iproduct!(100u64..1000u64, 100u64..1000u64)
.filter(|(x, y)| x <= y)
.map(|(x, y)| x * y)
.filter(|z| is_palindromic(*z))
.max()
.unwrap();
println!("{}", ans);
}<|fim_prefix|>// repo: komori-n/ProjectEuler-rs path: /src/bin/problem_004.rs
use itertools::iproduct;
use project_euler_... | code_fim | easy | {
"lang": "rust",
"repo": "komori-n/ProjectEuler-rs",
"path": "/src/bin/problem_004.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> |
// |
println!("a: {}", a); // |
add_one(&1); //&1 must live as long as the function
} // ---- a is freed ---------|
fn add_one<'a>(x: &'a i32) {
println... | code_fim | hard | {
"lang": "rust",
"repo": "smerrell/rust-presentation",
"path": "/src/lifetimes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: smerrell/rust-presentation path: /src/lifetimes.rs
pub fn lifetimes() {
// lifetimes are what help the compiler reason about how long
// references have to live in the program.
//
// Local references live only as long as their scope, but once
// we bring in borrowing, referen... | code_fim | hard | {
"lang": "rust",
"repo": "smerrell/rust-presentation",
"path": "/src/lifetimes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn parse_line<T: LogParser>(parser: &mut T, line: &str, line_number: u32) -> Result<(), LogParserError> {
if !parser.complete() {
try!(parser.parse_line(line, line_number as u32));
};
Ok(())
}
fn finish_parse<T: LogParser>(parser: &mut T, final_line_number: u32,
... | code_fim | hard | {
"lang": "rust",
"repo": "jgraham/th-logparser-rust",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jgraham/th-logparser-rust path: /src/lib.rs
extern crate chrono;
#[macro_use]
extern crate lazy_static;
extern crate libc;
extern crate regex;
extern crate rustc_serialize;
extern crate time;
extern crate hyper;
extern crate flate2;
pub mod http;
pub mod logparser;
pub mod performanceparser;
pu... | code_fim | hard | {
"lang": "rust",
"repo": "jgraham/th-logparser-rust",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
impl I2SMOD_R {
#[doc = "Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> I2SMOD_A {
match self.bits {
false => I2SMOD_A::Spimode,
true => I2SMOD_A::I2smode,
}
}
#[doc = "SPI mode is se... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32f7/src/stm32f7x3/spi1/i2scfgr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32f7/src/stm32f7x3/spi1/i2scfgr.rs
om(variant: CHLEN_A) -> Self {
variant as u8 != 0
}
}
impl CHLEN_R {
#[doc = "Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> CHLEN_A {
match self.bits {
... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32f7/src/stm32f7x3/spi1/i2scfgr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32f7/src/stm32f7x3/spi1/i2scfgr.rs
ATLEN_A::SixteenBit)
}
#[doc = "24-bit data length"]
#[inline(always)]
pub fn twenty_four_bit(self) -> &'a mut crate::W<REG> {
self.variant(DATLEN_A::TwentyFourBit)
}
#[doc = "32-bit data len... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32f7/src/stm32f7x3/spi1/i2scfgr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn map_seat(layout: &Layout, row: usize, col: usize) -> SeatKind {
match layout.seat_map[row][col] {
SeatKind::Floor => SeatKind::Floor,
SeatKind::Empty => match get_seat_adjs(layout, row, col)
.iter()
.map(|(next_row, next_col)| layout.s... | code_fim | hard | {
"lang": "rust",
"repo": "whichxjy/aoc-2020",
"path": "/day-11/src/main.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.