text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> }
println!("rust fiber {}: after sleep", fiber_id);
}
}<|fim_prefix|>// repo: yetialex/tarantool-rust path: /src/example.rs
extern crate core;
include!("./module.rs");
#[no_mangle]
pub extern fn rustproc(fiber_id: u64) {
for _ in 0..5 {
println!("rust fiber {}<|fim_middle... | code_fim | medium | {
"lang": "rust",
"repo": "yetialex/tarantool-rust",
"path": "/src/example.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yetialex/tarantool-rust path: /src/example.rs
extern crate core;
include!("./module.rs");
#[no_mangle]
pub extern fn ru<|fim_suffix|>: before sleep", fiber_id);
unsafe {
fiber_sleep(0.1);
}
println!("rust fiber {}: after sleep", fiber_id);
}
}<|fim_middle... | code_fim | medium | {
"lang": "rust",
"repo": "yetialex/tarantool-rust",
"path": "/src/example.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>: before sleep", fiber_id);
unsafe {
fiber_sleep(0.1);
}
println!("rust fiber {}: after sleep", fiber_id);
}
}<|fim_prefix|>// repo: yetialex/tarantool-rust path: /src/example.rs
extern crate core;
include!("./module.rs");
#[no_mangle]
pub extern fn ru<|fim_middle... | code_fim | medium | {
"lang": "rust",
"repo": "yetialex/tarantool-rust",
"path": "/src/example.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> MerkleLeafStr(FrStr(origin[0]))
}
}
impl Serialize for l2::TxType {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_i32(match self {
l2::TxType::Nop => 0,
l2::TxType::Deposit => 1,
l2::T... | code_fim | hard | {
"lang": "rust",
"repo": "lightsing/rollup-state-manager",
"path": "/src/test_utils/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>//array::map is not stable
fn array_map<U, T: Clone + Into<U>, const N: usize>(origin: [T; N]) -> [U; N] {
let mut collector: Vec<U> = Vec::new();
for i in &origin {
collector.push(i.clone().into());
}
TryFrom::try_from(collector).ok().unwrap()
}
fn from_merkle<const N: usize>(ori... | code_fim | hard | {
"lang": "rust",
"repo": "lightsing/rollup-state-manager",
"path": "/src/test_utils/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lightsing/rollup-state-manager path: /src/test_utils/mod.rs
pub mod circuit;
pub mod messages;
pub mod types;
pub use crate::types::l2;
pub use crate::types::merkle_tree::MerklePath;
pub use crate::types::primitives::{fr_to_string, u64_to_fr, Fr};
pub use circuit::{format_circuit_name, CircuitS... | code_fim | hard | {
"lang": "rust",
"repo": "lightsing/rollup-state-manager",
"path": "/src/test_utils/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn println_signers(
blockhash: &Hash,
signers: &[String],
absent: &[String],
bad_sig: &[String],
) {
println!();
println!("Blockhash: {}", blockhash);
if !signers.is_empty() {
println!("Signers (Pubkey=Signature):");
signers.iter().for_each(|signer| println!... | code_fim | medium | {
"lang": "rust",
"repo": "metaversefight/solana",
"path": "/cli/src/display.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: metaversefight/solana path: /cli/src/display.rs
use crate::cli::SettingType;
use console::style;
use solana_sdk::hash::Hash;
// Pretty print a "name value"
pub fn println_name_value(name: &str, value: &str) {
let styled_value = if value == "" {
style("(not set)").italic()
} else... | code_fim | hard | {
"lang": "rust",
"repo": "metaversefight/solana",
"path": "/cli/src/display.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> fmt::Display for ItemSet<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "The set has a total value of {}", self.value)?;
writeln!(f, " Light: {}", self.light)?;
writeln!(f, " Finger: {}", self.finger1)?;
writeln!(f, " F... | code_fim | hard | {
"lang": "rust",
"repo": "steven-joruk/equipment-optimizer",
"path": "/src/itemset.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: steven-joruk/equipment-optimizer path: /src/itemset.rs
use crate::item::Item;
use std::convert::TryFrom;
use std::fmt;
#[derive(Clone)]
pub struct ItemSet<'a> {
pub value: i32,
light: &'a Item,
finger1: &'a Item,
finger2: &'a Item,
neck1: &'a Item,
neck2: &'a Item,
... | code_fim | hard | {
"lang": "rust",
"repo": "steven-joruk/equipment-optimizer",
"path": "/src/itemset.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: quark-zju/wezterm path: /promise/src/lib.rs
use anyhow::Error;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use std::task::{Context, Poll, Waker};
use thiserror::*;
pub mod spawn;
#[derive(Debug, Error)]
#[error("Promise was dropped before completion")]
pub struct BrokenPromise {}
#[derive... | code_fim | hard | {
"lang": "rust",
"repo": "quark-zju/wezterm",
"path": "/promise/src/lib.rs",
"mode": "psm",
"license": "OFL-1.1",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Create a leaf future which is immediately ready with
/// the provided error
pub fn err(err: Error) -> Self {
Self::result(Err(err))
}
/// Create a leaf future which is immediately ready with
/// the provided result
pub fn result(result: Result<T, Error>) -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "quark-zju/wezterm",
"path": "/promise/src/lib.rs",
"mode": "spm",
"license": "OFL-1.1",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reujab/wallpaper.rs path: /src/linux/xfce.rs
use crate::{get_stdout, run, Error, Mode, Result};
use std::path::Path;
fn get_desktop_props(key: &str) -> Result<Vec<String>> {
let stdout = get_stdout("xfconf-query", &["--channel", "xfce4-desktop", "--list"])?;
let desktops = stdout
... | code_fim | hard | {
"lang": "rust",
"repo": "reujab/wallpaper.rs",
"path": "/src/linux/xfce.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
pub fn set_mode(mode: Mode) -> Result<()> {
for property in get_desktop_props("image-style")? {
run(
"xfconf-query",
&[
"--channel",
"xfce4-desktop",
"--property",
&property,
"... | code_fim | hard | {
"lang": "rust",
"repo": "reujab/wallpaper.rs",
"path": "/src/linux/xfce.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Camera {
pub fn new(
look_from: Vec3,
look_to: Vec3,
vup: Vec3,
vfov: f32,
aspect: f32,
aperture: f32,
focus_dist: f32,
) -> Camera {
// construct camera:
// :look_from: location of the camera
// :look_to: ... | code_fim | medium | {
"lang": "rust",
"repo": "rk9109/rt-wasm",
"path": "/src/camera.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rk9109/rt-wasm path: /src/camera.rs
use std::f32;
use rand::Rng;
use rand_pcg;
use crate::ray::Ray;
use crate::vec::Vec3;
pub fn random_point_in_disk(rng: &mut rand_pcg::Pcg64) -> Vec3 {
// return a random point inside the unit circle
let unit = Vec3::new(1.0, 1.0, 0.0);
loop {
... | code_fim | hard | {
"lang": "rust",
"repo": "rk9109/rt-wasm",
"path": "/src/camera.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: leighpauls/rust_tetris path: /src/field.rs
use piston::input::RenderArgs;
use block::Block;
use tetronimo::Tetromino;
use graphics::Context;
use opengl_graphics::GlGraphics;
use tetronimo::RotDir;
use shape_bag::ShapeBag;
use trans2d::Trans2D;
use BLACK;
pub struct FieldDrawParams {
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "leighpauls/rust_tetris",
"path": "/src/field.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let stash_params = FieldDrawParams::new_stash(render_args);
self.draw_field_lines(c, gl, &stash_params);
if let &Some(ref t) = &self.stash_tet {
t.draw(c, &stash_params, gl);
}
for preview_idx in 0..5 {
let preview_params = FieldDrawParams::... | code_fim | hard | {
"lang": "rust",
"repo": "leighpauls/rust_tetris",
"path": "/src/field.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MiyamonY/atcoder path: /agc/032/a/01/src/main.rs
#[allow(unused_macros)]
macro_rules! scan {
() => {
{
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().to_string()
}
};
(;;) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "MiyamonY/atcoder",
"path": "/agc/032/a/01/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ans = vec![];
while !vs.is_empty() {
for i in 0..vs.len() {
let n = vs.len();
if vs[vs.len() - i - 1] == vs.len() - i {
ans.push(vs.remove(n - i - 1));
break;
}
}
}
for a in ans.iter().rev() {
... | code_fim | hard | {
"lang": "rust",
"repo": "MiyamonY/atcoder",
"path": "/agc/032/a/01/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> Dictionary<'a> {
pub fn define(&mut self, id: CharacterId, character: Character<'a>) {
assert!(
self.characters.insert(id, character).is_none(),
"Dictionary::define: ID {} is already taken"
);
}
}<|fim_prefix|>// repo: LykenSol/flashback path: /src... | code_fim | medium | {
"lang": "rust",
"repo": "LykenSol/flashback",
"path": "/src/dictionary.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Sprite(Timeline<'a>),
Button(Button),
DynamicText(&'a swf::tags::DefineDynamicText),
}
#[derive(Default)]
pub struct Dictionary<'a> {
pub characters: BTreeMap<CharacterId, Character<'a>>,
}
impl<'a> Dictionary<'a> {
pub fn define(&mut self, id: CharacterId, character: Character<'a>) ... | code_fim | medium | {
"lang": "rust",
"repo": "LykenSol/flashback",
"path": "/src/dictionary.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LykenSol/flashback path: /src/dictionary.rs
use crate::bitmap::Bitmap;
use crate::button::Button;
use crate::shape::Shape;
use crate::sound::Sound;
use crate::timeline::Timeline;
use std::collections::BTreeMap;
use swf_types as swf;
<|fim_suffix|>#[derive(Default)]
pub struct Dictionary<'a> {
... | code_fim | hard | {
"lang": "rust",
"repo": "LykenSol/flashback",
"path": "/src/dictionary.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct Lexer {
vis: Visibility,
name: Ident,
input: Ident,
lifetime: Option<Lifetime>,
return_type: Type,
rules: Vec<Rule>,
}
impl Synom for Lexer {
named!(parse -> Self, do_parse!(
vis: syn!(Visibility) >>
keyword!(fn) >>
name: syn!(Ident) >>
i... | code_fim | hard | {
"lang": "rust",
"repo": "martin-t/plex",
"path": "/src/lexer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let compute_result = {
let compute_arms = actions.into_iter().enumerate().map(|(i, expr)| {
let i = i as u32;
quote!(#i => #expr)
});
quote!(match which {
#(#compute_arms,)*
_ => unreachable!()
})
};
let lifetime =... | code_fim | hard | {
"lang": "rust",
"repo": "martin-t/plex",
"path": "/src/lexer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: martin-t/plex path: /src/lexer.rs
use std::collections::{BTreeSet, VecDeque};
use std::char;
use redfa::Dfa;
use redfa::regex::Regex;
use syn;
use syn::buffer::Cursor;
use syn::synom::{PResult, Synom};
use syn::{Expr, Ident, Lifetime, LitStr, Type, Visibility};
use proc_macro2::{Delimiter, Spa... | code_fim | hard | {
"lang": "rust",
"repo": "martin-t/plex",
"path": "/src/lexer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ErinTorno/shax path: /src/lua/entity.rs
use bevy::prelude::*;
use enumset::*;
use rlua::prelude::*;
use crate::lua::types::*;
use crate::lua::util::*;
#[derive(Debug, EnumSetType)]
pub enum EntityEvent {
OnInit,
OnUpdate,
}
impl EntityEvent {
pub fn from_string(str: &str) -> Resul... | code_fim | hard | {
"lang": "rust",
"repo": "ErinTorno/shax",
"path": "/src/lua/entity.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl LuaUserData for LuaEntity {
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
methods.add_method("id", |_, this, ()| {
Ok(this.entity.id())
});
methods.add_method_mut("register", |lua_ctx, this, table: LuaTable| {
let new_id... | code_fim | hard | {
"lang": "rust",
"repo": "ErinTorno/shax",
"path": "/src/lua/entity.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 2over12/sire path: /src/analysis.rs
use rustc::mir::*;
pub fn find_loop<'tcx>(mir: &'tcx Mir<'tcx>) -> Option<Vec<BasicBlock>> {
get_loop_start(mir, BasicBlock::from_u32(0), Vec::new())
}
<|fim_suffix|> mir: &'tcx Mir<'tcx>,
block: BasicBlock,
mut visited: Vec<BasicBlock>,
) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "2over12/sire",
"path": "/src/analysis.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> mir: &'tcx Mir<'tcx>,
block: BasicBlock,
mut visited: Vec<BasicBlock>,
) -> Option<Vec<BasicBlock>> {
match visited.iter().enumerate().find(|(_, b)| **b == block) {
Some((i, _)) => Some(visited.split_off(i)),
None => {
let blk = mir.basic_blocks().get(block)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "2over12/sire",
"path": "/src/analysis.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[wasm_bindgen_test]
async fn markdown_worker_works() {
let mut bridge =
MarkdownWorker::spawner().spawn("http://127.0.0.1:9999/example_markdown_worker.js");
let content = bridge.run(MARKDOWN_CONTENT.to_owned()).await;
assert_eq!(
&content,
... | code_fim | medium | {
"lang": "rust",
"repo": "rustwasm/gloo",
"path": "/examples/markdown/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> wasm_bindgen_test_configure!(run_in_browser);
static MARKDOWN_CONTENT: &str = r#"
## Hello
This content is *rendered* by a **web worker**.
"#;
#[wasm_bindgen_test]
async fn markdown_worker_works() {
let mut bridge =
MarkdownWorker::spawner().spawn("http://127.0.0.1:... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/gloo",
"path": "/examples/markdown/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustwasm/gloo path: /examples/markdown/src/lib.rs
use gloo::worker::oneshot::oneshot;
use pulldown_cmark::{html, Parser};
#[oneshot]
pub async fn MarkdownWorker(input: String) -> String {
let parser = Parser::new(&input);
let mut output = String::new();
html::push_html(&mut output,... | code_fim | hard | {
"lang": "rust",
"repo": "rustwasm/gloo",
"path": "/examples/markdown/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flier/rustfmt path: /tests/source/configs-fn_args_paren_newline-true.rs
// rustfmt-fn_args_paren_newline: true
// Function arguments parenthesis on a newline
fn lorem(ipsum: Ipsum, dolor: Dolor, <|fim_suffix|>LoremIpsumDolorSitAmetConsecteturAdipiscingElit {
// body
}<|fim_middle|>sit: Sit,... | code_fim | medium | {
"lang": "rust",
"repo": "flier/rustfmt",
"path": "/tests/source/configs-fn_args_paren_newline-true.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>LoremIpsumDolorSitAmetConsecteturAdipiscingElit {
// body
}<|fim_prefix|>// repo: flier/rustfmt path: /tests/source/configs-fn_args_paren_newline-true.rs
// rustfmt-fn_args_paren_newline: true
// Function arguments parenthesis on a newline
fn lorem(ipsum: Ipsum, dolor: Dolor, <|fim_middle|>sit: Sit,... | code_fim | medium | {
"lang": "rust",
"repo": "flier/rustfmt",
"path": "/tests/source/configs-fn_args_paren_newline-true.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: C-W-M-Oliver8012/Variable_Security_Language-VSL path: /vsl_vm/src/main.rs
use std::env;
use std::fs;
use std::time::Instant;
mod vm;
fn main() {
let start = Instant::now();
let args: Vec<String> = env::args().collect();
if args.len() == 2 {
let filename = &args[1];
let bytes: Vec<u8> = ... | code_fim | hard | {
"lang": "rust",
"repo": "C-W-M-Oliver8012/Variable_Security_Language-VSL",
"path": "/vsl_vm/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut program: Vec<i64> = Vec::new();
let mut byte_count = 0;
let mut chunk_value: i64 = 0;
for byte in bytes {
if byte_count == 0 {
chunk_value = (byte as i64) << 56;
byte_count += 1;
} else if byte_count == 1 {
chunk_value |= (byte as i64) << 48;
... | code_fim | hard | {
"lang": "rust",
"repo": "C-W-M-Oliver8012/Variable_Security_Language-VSL",
"path": "/vsl_vm/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hcpl/mtproto-rs path: /tl_codegen/src/lib.rs
#[macro_use]
extern crate error_chain;
extern crate petgraph;
extern crate pom;
#[macro_use]
extern crate quote;
extern crate syn;
#[cfg(feature = "parsing")]
extern crate synom;
<|fim_suffix|>pub use generator::generate_ast_for;
pub use generator::... | code_fim | medium | {
"lang": "rust",
"repo": "hcpl/mtproto-rs",
"path": "/tl_codegen/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub use generator::generate_ast_for;
pub use generator::generate_code_for;<|fim_prefix|>// repo: hcpl/mtproto-rs path: /tl_codegen/src/lib.rs
#[macro_use]
extern crate error_chain;
extern crate petgraph;
extern crate pom;
#[macro_use]
extern crate quote;
extern crate syn;
#[cfg(feature = "parsing")]
ext... | code_fim | medium | {
"lang": "rust",
"repo": "hcpl/mtproto-rs",
"path": "/tl_codegen/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Compile tests
#[java(class = "java.lang.Foo", name = "Bar")]
fn func(env: &JNIEnv) {
}
#[java(class = "java.lang.Foo", name = "Foo")]
fn func(env: &JNIEnv, _this: JObject, _arg1: JClass, _arg2: Option<JString>) -> JObject {
JObject::new(std::ptr::null_mut()).unwrap()
... | code_fim | hard | {
"lang": "rust",
"repo": "CraftSpider/rust-jni",
"path": "/src/vm.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CraftSpider/rust-jni path: /src/vm.rs
//!
//! Module containing a higher-level wrapper over a raw JVM. This higher-level implementation
//! can handle automatic creation/destruction, all the Invoke Interface functions, and tries to
//! ensure safety while doing so.
//!
use crate::{env, ffi};
us... | code_fim | hard | {
"lang": "rust",
"repo": "CraftSpider/rust-jni",
"path": "/src/vm.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>nect
:
LPOCNCONNPROCW
pvUserData
:
LPVOID
dwShareMode
:
DWORD
dwPreferredProtocols
:
DWORD
lpstrRdr
:
LPWSTR
nMaxRdr
:
DWORD
lpstrCard
:
LPWSTR
nMaxCard
:
DWORD
dwActiveProtocol
:
DWORD
hCardHandle
:
SCARDHANDLE
}
}
pub
type
POPENCARDNAME_EXW
=
*
mut
OPENCARDNAME_EXW
;
pub
type
LPOPENCARDNAME_EXW
=
*
mut
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/winapi/src/um/winscard.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ation
:
DWORD
pdwActiveProtocol
:
LPDWORD
)
-
>
LONG
;
pub
fn
SCardDisconnect
(
hCard
:
SCARDHANDLE
dwDisposition
:
DWORD
)
-
>
LONG
;
pub
fn
SCardBeginTransaction
(
hCard
:
SCARDHANDLE
)
-
>
LONG
;
pub
fn
SCardEndTransaction
(
hCard
:
SCARDHANDLE
dwDisposition
:
DWORD
)
-
>
LONG
;
pub
fn
SCardState
(
hCa... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/winapi/src/um/winscard.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/winapi/src/um/winscard.rs
nnt
:
:
{
CHAR
HANDLE
LONG
LPCSTR
LPCWSTR
LPSTR
LPWSTR
PVOID
WCHAR
}
;
use
um
:
:
winsmcrd
:
:
{
LPCSCARD_IO_REQUEST
LPSCARD_IO_REQUEST
}
;
pub
type
LPCBYTE
=
*
const
BYTE
;
pub
type
SCARDCONTEXT
=
ULONG_PTR
;
pub
type... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/winapi/src/um/winscard.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wamdue/Algorithms path: /quick_sort/src/main.rs
use rand;
use rand::Rng;
use std::time::SystemTime;
use rand::prelude::ThreadRng;
use std::borrow::BorrowMut;
fn main() {
let mut arr = [0; 10000];
let mut arr2 = [0; 10000];
let mut rand = rand::thread_rng();
for i in 0..arr.len()... | code_fim | hard | {
"lang": "rust",
"repo": "wamdue/Algorithms",
"path": "/quick_sort/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pivot = arr[high - 1];
let mut i = low;
for j in low..high - 1 {
if arr[j] <= pivot {
arr.swap(i, j);
i += 1;
}
}
arr.swap(i, high - 1);
i
}
fn quick_sort(arr: &mut [i32], low: usize, high: usize) {
if low < high {
let q = pa... | code_fim | hard | {
"lang": "rust",
"repo": "wamdue/Algorithms",
"path": "/quick_sort/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut array = [10, 5, 3, 6, 4, 2, 8, 0, 11, 1];
let result = [0, 1, 2, 3, 4, 5, 6, 8, 10, 11];
let size = array.len();
let mut rand = rand::thread_rng();
randomized_quicksort(array.as_mut(), 0, size, rand.borrow_mut());
assert_eq!(array, result);
}
}<... | code_fim | hard | {
"lang": "rust",
"repo": "wamdue/Algorithms",
"path": "/quick_sort/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn apply_ty_substs<'a, 'tcx>(tcx: &TyCtxt<'a, 'tcx, 'tcx>, ty_substs: &Substs<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
let substituted = ty.subst(*tcx, ty_substs);
tcx.normalize_associated_type(&substituted)
}<|fim_prefix|>// repo: msiglreith/inspirv-rust path: /src/legacy/monomorphize.rs
use rustc... | code_fim | hard | {
"lang": "rust",
"repo": "msiglreith/inspirv-rust",
"path": "/src/legacy/monomorphize.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: msiglreith/inspirv-rust path: /src/legacy/monomorphize.rs
use rustc::ty::subst::{Subst, Substs};
use rustc::ty::{Ty, TyCtxt, TypeFoldable};
use rustc::infer::TransNormalize;
<|fim_suffix|>pub fn apply_ty_substs<'a, 'tcx>(tcx: &TyCtxt<'a, 'tcx, 'tcx>, ty_substs: &Substs<'tcx>, ty: Ty<'tcx>) -> T... | code_fim | hard | {
"lang": "rust",
"repo": "msiglreith/inspirv-rust",
"path": "/src/legacy/monomorphize.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: image-rs/imageproc path: /src/gradients.rs
//! Functions for computing gradients of image intensities.
use crate::definitions::{HasBlack, Image};
use crate::filter::filter3x3;
use crate::map::{ChannelMap, WithChannel};
use image::{GenericImage, GenericImageView, GrayImage, Luma, Pixel};
use ite... | code_fim | hard | {
"lang": "rust",
"repo": "image-rs/imageproc",
"path": "/src/gradients.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let filtered = horizontal_sobel(&image);
assert_pixels_eq!(filtered, expected);
}
#[test]
fn test_vertical_sobel_gradient_image() {
let image = gray_image!(
3, 6, 9;
2, 5, 8;
1, 4, 7);
let expected = gray_image!(type: i16,
... | code_fim | hard | {
"lang": "rust",
"repo": "image-rs/imageproc",
"path": "/src/gradients.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let image = gray_image!(
3, 2, 1;
6, 5, 4;
9, 8, 7);
let expected = gray_image!(type: i16,
-4, -8, -4;
-4, -8, -4;
-4, -8, -4);
let filtered = horizontal_sobel(&image);
assert_pixels_eq!(filtered, exp... | code_fim | hard | {
"lang": "rust",
"repo": "image-rs/imageproc",
"path": "/src/gradients.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vgatherps/first_in_line path: /src/displacement.rs
use crate::exchange::normalized::MarketUpdates;
use crate::signal_graph::graph_registrar::*;
use crate::signal_graph::interface_types::*;
use std::collections::{HashMap, HashSet};
// What's the algorithm?
// Look at the displacement of a fast ... | code_fim | hard | {
"lang": "rust",
"repo": "vgatherps/first_in_line",
"path": "/src/displacement.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn create(
mut outputs: HashMap<&'static str, ConsumerOutput>,
mut inputs: InputLoader,
_: Option<&str>,
) -> Result<Self, anyhow::Error> {
Ok(Premium {
in1: inputs.load_input("in1")?,
in2: inputs.load_input("in2")?,
diff: outputs... | code_fim | hard | {
"lang": "rust",
"repo": "vgatherps/first_in_line",
"path": "/src/displacement.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/*
impl Displacement {
pub fn handle_local(&mut self, local_fair: f64, local_size: f64) {
let lf = self.local_fast_ema.add_value(local_fair);
self.local_slow_ema.add_value(local_fair);
self.local_size.add_value(local_size);
if let Some(rf) = self.remote_fast_ema.get_val... | code_fim | hard | {
"lang": "rust",
"repo": "vgatherps/first_in_line",
"path": "/src/displacement.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust-analyzer path: /crates/syntax/test_data/parser/fuzz-failures/0000.rs
//! An experimental implementation of [Rust RFC#2256 lrs);
let root = SyntaxNode::new_owned(root);
validate_block_structure(root.borrowed());
File { root }
}
pub fn parse(text: &st... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust-analyzer",
"path": "/crates/syntax/test_data/parser/fuzz-failures/0000.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn delete(range: TextRange) -> AtomTextEdit {
AtomTextEdit::replace(range, String::new())
}
pub fn insert(offset: TextUnit, text: String) -> AtomTextEdit {
AtomTextEdit::replace(TextRange::offset_len(offset, 0.into()), text)
}
}
fn find_reparsable_node(node: SyntaxNod... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust-analyzer",
"path": "/crates/syntax/test_data/parser/fuzz-failures/0000.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = match node.kind() {
;
let end = u32::from(range.end()) as usize;
text.replaT => grammar::record_field_list,
_ => return None,
};
Some(res)
}
}
pub /*(meh)*/ fn replace_range(mut text: String, range: TextRange, replace_with: &str) -> String {
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust-analyzer",
"path": "/crates/syntax/test_data/parser/fuzz-failures/0000.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brianjp93/aoc2019-rust path: /src/days/day6.rs
use std::collections::{HashMap, HashSet};
use std::fs;
pub fn main() {
let data = fs::read_to_string("./src/data/day6.txt").expect("Error");
let data_list: Vec<_> = data.trim().split("\n").collect();
let planets = get_planet_hashmap(da... | code_fim | hard | {
"lang": "rust",
"repo": "brianjp93/aoc2019-rust",
"path": "/src/days/day6.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if name == "COM" {
0
} else if self.map.get(&name.to_string()).unwrap().dist > 0 {
self.map.get(&name.to_string()).unwrap().dist
} else {
let next_name = self.map.get(&name.to_string()).unwrap().name.clone();
let new_dist = self.get_d... | code_fim | hard | {
"lang": "rust",
"repo": "brianjp93/aoc2019-rust",
"path": "/src/days/day6.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (consensus_public_key, consensus_secret_key) = exonum::crypto::gen_keypair();
let (service_public_key, service_secret_key) = exonum::crypto::gen_keypair();
let validator_keys = ValidatorKeys {
consensus_key: consensus_public_key,
service_key: service_public_key,
};
... | code_fim | medium | {
"lang": "rust",
"repo": "KateNegrienko/exonum",
"path": "/examples/cryptocurrency/examples/demo.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Creating in-memory database...");
let node = Node::new(
MemoryDB::new(),
vec![Box::new(CurrencyService)],
node_config(),
None,
);
println!("Starting a single node...");
println!("Blockchain is ready for transactions!");
node.run().unwrap();... | code_fim | hard | {
"lang": "rust",
"repo": "KateNegrienko/exonum",
"path": "/examples/cryptocurrency/examples/demo.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KateNegrienko/exonum path: /examples/cryptocurrency/examples/demo.rs
// Copyright 2018 The Exonum Team
//
// 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
//
// http... | code_fim | medium | {
"lang": "rust",
"repo": "KateNegrienko/exonum",
"path": "/examples/cryptocurrency/examples/demo.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Trait for recursive tracer
///
/// The input type of nom parser must implement this.
pub trait HasRecursiveInfo {
fn get_recursive_info(&self) -> RecursiveInfo;
fn set_recursive_info(self, info: RecursiveInfo) -> Self;
}
impl HasRecursiveInfo for RecursiveInfo {
fn get_recursive_info(&sel... | code_fim | hard | {
"lang": "rust",
"repo": "dalance/nom-recursive",
"path": "/nom-recursive/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dalance/nom-recursive path: /nom-recursive/src/lib.rs
//! `nom-recursive` is an extension of [nom](https://docs.rs/nom) to handle left recursion.
//!
//! ## Examples
//!
//! The following example show a quick example.
//! If `#[recursive_parser]` is removed, stack overflow will occur because of ... | code_fim | hard | {
"lang": "rust",
"repo": "dalance/nom-recursive",
"path": "/nom-recursive/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: itn3000/ms-ssrp-rs path: /src/lib.rs
#[macro_use]
extern crate log;
use std::net::UdpSocket;
use std::io::Error;
use std::net::IpAddr;
use std::net::{Ipv4Addr, Ipv6Addr};
// use std::net::IpAddr::{V4, V6};
use std::net::SocketAddr;
use std::time::Duration;
use std::io::ErrorKind;
// use std::io... | code_fim | hard | {
"lang": "rust",
"repo": "itn3000/ms-ssrp-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let localsockaddr = SocketAddr::new(
match is_ipv4 {
true => IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
false => IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)),
},
0,
);
let sock = UdpSocket::bind(localsockaddr)?;... | code_fim | hard | {
"lang": "rust",
"repo": "itn3000/ms-ssrp-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> const SVR_RESP_ID : u8 = 0x5;
let mut ret: Vec<u8> = Vec::new();
ret.reserve(512);
let mut recvbuf = [0u8; 512];
let mut is_header_received: bool = false;
let mut datalength: i32 = -1;
while datalength < 0 || ret.len() < datalength as usize {
... | code_fim | hard | {
"lang": "rust",
"repo": "itn3000/ms-ssrp-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dnorman/unbase path: /crates/unbase/src/slab/memo/mod.rs
// Memo
// A memo is an immutable message.
pub mod serde;
use core::ops::Deref;
use futures::future::{
BoxFuture,
FutureExt,
};
use std::{
collections::HashMap,
fmt,
sync::Arc,
};
use crate::{
error::RetrieveError... | code_fim | hard | {
"lang": "rust",
"repo": "dnorman/unbase",
"path": "/crates/unbase/src/slab/memo/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug)]
pub enum MemoBody {
SlabPresence {
p: SlabPresence,
r: Head,
}, // TODO: split out root_index_seed conveyance to another memobody type
Relation(RelationSet),
Edge(EdgeSet),
Edit(HashMap<String, String>),
FullyMaterialized {
v: HashMap... | code_fim | hard | {
"lang": "rust",
"repo": "dnorman/unbase",
"path": "/crates/unbase/src/slab/memo/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO: parallelize this
// TODO: Use sparse-vector/beacon to avoid having to trace out the whole lineage
// Should be able to stop traversal once happens-before=true. Cannot descend a thing that happens after
async move {
// breadth-first
for... | code_fim | hard | {
"lang": "rust",
"repo": "dnorman/unbase",
"path": "/crates/unbase/src/slab/memo/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexandercampbell/halftau path: /src/lex.rs
use crate::model::Token;
use crate::model::TokenType::*;
pub fn lex(s: String) -> Result<Vec<Token>, String> {
let mut tokens: Vec<Token> = vec![];
let mut line_number = 1usize;
let mut chars = s.chars().peekable();
loop {
le... | code_fim | hard | {
"lang": "rust",
"repo": "alexandercampbell/halftau",
"path": "/src/lex.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> '0'..='9' => {
let mut text = ch.to_string();
let mut is_double = false;
while let Some(next) = chars.peek() {
if *next == '.' {
if is_double {
return Err(format!(
... | code_fim | hard | {
"lang": "rust",
"repo": "alexandercampbell/halftau",
"path": "/src/lex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while let Some(next) = chars.peek() {
if *next == '.' {
if is_double {
return Err(format!(
"multiple decimal places in float literal on line {}",
line_num... | code_fim | hard | {
"lang": "rust",
"repo": "alexandercampbell/halftau",
"path": "/src/lex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ReviveChang/leetcode-rust path: /src/c_5649.rs
pub struct Solution;
impl Solution {
pub fn decode(encoded: Vec<i32>, first: i32) -> Vec<i32> {
let mut cur = first;
<|fim_suffix|>push(cur ^ n);
cur = cur ^n;
}
ans
}
}<|fim_middle|>let mut ans ... | code_fim | medium | {
"lang": "rust",
"repo": "ReviveChang/leetcode-rust",
"path": "/src/c_5649.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>push(cur ^ n);
cur = cur ^n;
}
ans
}
}<|fim_prefix|>// repo: ReviveChang/leetcode-rust path: /src/c_5649.rs
pub struct Solution;
impl Solution {
pub fn decode(encoded: Vec<i32>, first: i32) -> Vec<i32> {
let mut cur = first;
<|fim_middle|>let mut ans ... | code_fim | medium | {
"lang": "rust",
"repo": "ReviveChang/leetcode-rust",
"path": "/src/c_5649.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zenria/funtonic path: /common/src/config.rs
use crate::executor_meta::{ExecutorMeta, Tag};
use crate::file_utils::{parse_yaml_from_file, path_concat2, read};
use crate::tonic;
use anyhow::Error;
use serde::de::DeserializeOwned;
use serde::Deserialize;
use serde::Serialize;
use std::collections::... | code_fim | hard | {
"lang": "rust",
"repo": "zenria/funtonic",
"path": "/common/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_identity(&self) -> Result<Identity, anyhow::Error> {
let cert = read(&self.cert)?;
let key = read(&self.key)?;
Ok(Identity::from_pem(cert, key))
}
fn get_ca_certificate(&self) -> Result<Certificate, anyhow::Error> {
Ok(Certificate::from_pem(read(&self.ca... | code_fim | hard | {
"lang": "rust",
"repo": "zenria/funtonic",
"path": "/common/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ir210/chipmunk path: /application/apps/indexer-neon/native/src/dlt_stats_channel.rs
use channels::EventEmitterTask;
use dlt::dlt_parse::StatisticsResults;
use indexer_base::progress::{Notification, Severity};
use neon::prelude::*;
use std::fs;
use std::path;
use std::sync::mpsc::{self, Receiver,... | code_fim | hard | {
"lang": "rust",
"repo": "ir210/chipmunk",
"path": "/application/apps/indexer-neon/native/src/dlt_stats_channel.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Create an asynchronously `EventEmitterTask` to receive data
let events = cx.borrow(&this, |emitter| Arc::clone(&emitter.event_receiver));
let emitter = EventEmitterTask::new(events);
// Schedule the task on the `libuv` thread pool
emitter.sch... | code_fim | hard | {
"lang": "rust",
"repo": "ir210/chipmunk",
"path": "/application/apps/indexer-neon/native/src/dlt_stats_channel.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>crate::field_type! {
#[field: doc = "`field`: on nothing"]
struct StructField [u8] (u8);
}
crate::field_type! {
#[impl: doc = "`impl`: only on impls (obvoiusly not derived ones)"]
struct StructImpl [u8] (u8);
}
crate::field_type! {
#[all: doc = "`all`: on struct and impls (obvoiusly ... | code_fim | medium | {
"lang": "rust",
"repo": "kellda/peripherals",
"path": "/src/attributes/field_type.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kellda/peripherals path: /src/attributes/field_type.rs
//! An example of where attributes get expanded in [`field_type!`] macros
//!
//! Take a look at the source of this module to see the macro invocation used.
crate::field_type! {
#[doc = "Nothing: only on enum"]
enum Enum [u8] {
... | code_fim | hard | {
"lang": "rust",
"repo": "kellda/peripherals",
"path": "/src/attributes/field_type.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> div![
style! { St::Display => "flex"},
counter::view(&model.counter_a, || Msg::CounterClicked('A'), Msg::CounterA),
counter::view(&model.counter_b, || Msg::CounterClicked('B'), Msg::CounterB),
"See Console log",
]
}
// ------ ------
// Start
// ------ ------
#... | code_fim | medium | {
"lang": "rust",
"repo": "seed-rs/seed",
"path": "/examples/tea_component/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seed-rs/seed path: /examples/tea_component/src/lib.rs
// NOTE: Don't try to create as many components as possible.
// Try to reuse already existing `Msg` and other entities to prevent unnecessary nesting and complexity.
use gloo_console::log;
use seed::{prelude::*, *};
<|fim_suffix|>fn init(_:... | code_fim | medium | {
"lang": "rust",
"repo": "seed-rs/seed",
"path": "/examples/tea_component/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let path = Path::new(&path_str);
let path_basename = PathBuf::from(
path.file_name().unwrap()
);
let basename_str: String = path_basename
.into_os_string()
.into_string()
.unwrap();
return basename_str;
}<|fim_prefix|>// repo: jakewilliami/scripts path: /rust/dotf/src/main.rs
// use std::f... | code_fim | hard | {
"lang": "rust",
"repo": "jakewilliami/scripts",
"path": "/rust/dotf/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jakewilliami/scripts path: /rust/dotf/src/main.rs
// use std::fs::read_to_st;
use std::path::{Path, PathBuf};
// use std::ffi::OsString;
const DOTFILE_LIST: &str = "/Users/jakeireland/projects/scripts/rust/dotf/src/dotfiles.txt";
const DOTFILES_DEST: &str = "/Users/jakeireland/projects/scripts/... | code_fim | hard | {
"lang": "rust",
"repo": "jakewilliami/scripts",
"path": "/rust/dotf/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn basename(path_str: &str) -> String {
let path = Path::new(&path_str);
let path_basename = PathBuf::from(
path.file_name().unwrap()
);
let basename_str: String = path_basename
.into_os_string()
.into_string()
.unwrap();
return basename_str;
}<|fim_prefix|>// repo: jakewilliami/scripts pa... | code_fim | hard | {
"lang": "rust",
"repo": "jakewilliami/scripts",
"path": "/rust/dotf/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(Instruction {
opcode: op,
immediate,
})
}
impl ProgramBuilder {
pub fn new() -> Self {
Self {
labels: HashMap::new(),
instructions: Vec::new(),
}
}
pub fn add_label(&mut self, name: &str, index: usize) {
self.labels.i... | code_fim | hard | {
"lang": "rust",
"repo": "rust-chainblock/clockchain",
"path": "/assembler/src/pre.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-chainblock/clockchain path: /assembler/src/pre.rs
//! Handles parsing and validation of programs before labels are
//! removed and replaced with relative jumps.
use crate::{Error, OpCode, Result};
use std::collections::HashMap;
#[derive(PartialEq, Debug)]
pub enum Immediate {
Label(S... | code_fim | hard | {
"lang": "rust",
"repo": "rust-chainblock/clockchain",
"path": "/assembler/src/pre.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aharpole/adventofcode-2019 path: /src/intcode.rs
use std::convert::TryInto;
type Word = i64;
type Memory = Vec<Word>;
#[derive(Clone)]
pub struct IntcodeComputer {
eip: usize,
pub prog: Memory,
relbase: Word,
}
const OP_ADD: Word = 1;
const OP_MULTIPLY: Word = 2;
const OP_INPUT: W... | code_fim | hard | {
"lang": "rust",
"repo": "aharpole/adventofcode-2019",
"path": "/src/intcode.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn run_with_halt<State, F>(
mut self,
initial_input: Option<Word>,
initial_state: State,
reducer: F,
) -> State
where
F: Fn(Option<Word>, State) -> (Option<Word>, State, bool),
{
let mut input = initial_input;
let mut state = init... | code_fim | hard | {
"lang": "rust",
"repo": "aharpole/adventofcode-2019",
"path": "/src/intcode.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> OP_JUMP_NONZERO => {
let args = get_args(&mut self.prog, 2);
if args[0] != 0 {
args[1] as usize
} else {
self.eip + 3
}
}
OP_JUMP_ZERO => {
let args ... | code_fim | hard | {
"lang": "rust",
"repo": "aharpole/adventofcode-2019",
"path": "/src/intcode.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dtn7/dtn7-plus-rs path: /src/serde.rs
pub mod base64_or_bytes {
use base64::display::Base64Display;
use serde::{Deserializer, Serializer};
#[allow(clippy::ptr_arg)]
pub fn serialize<S: Serializer>(v: &Vec<u8>, s: S) -> Result<S::Ok, S::Error> {
if s.is_human_readable() {... | code_fim | hard | {
"lang": "rust",
"repo": "dtn7/dtn7-plus-rs",
"path": "/src/serde.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> where
E: serde::de::Error,
{
self.visit_bytes(v.as_ref())
}
}
d.deserialize_str(Visitor)
} else {
serde_bytes::deserialize(d)
}
}
}<|fim_prefix|>// repo: dtn7/dt... | code_fim | hard | {
"lang": "rust",
"repo": "dtn7/dtn7-plus-rs",
"path": "/src/serde.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/derive_more/tests/error/nightly/derives_for_enums_with_backtrace.rs
use
super
:
:
*
;
derive_display
!
(
TestErr
)
;
#
[
derive
(
Debug
Error
)
]
enum
TestErr
{
Unit
NamedImplicitNoBacktrace
{
field
:
i32
}
NamedImplicitBacktraceByFieldName
{
b... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/derive_more/tests/error/nightly/derives_for_enums_with_backtrace.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rent
field
:
0
}
;
assert
!
(
err
.
backtrace
(
)
.
is_some
(
)
)
;
assert_bt
!
(
=
=
err
.
get_stored_backtrace
)
;
assert_bt
!
(
!
=
err
.
get_unused_backtrace
)
;
}
#
[
test
]
fn
unnamed_implicit_no_backtrace
(
)
{
let
err
=
TestErr
:
:
UnnamedImplicitNoBacktrace
(
0
0
)
;
assert
!
(
err
.
backtrace
(
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/derive_more/tests/error/nightly/derives_for_enums_with_backtrace.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: burrbull/vl6180x path: /src/dmax_ranging.rs
#define _DMaxData(field) VL6180xDevDataGet(dev, DMaxData.field)
/*
* Convert fix point x.7 to KCpount per sec
*/
#ifndef VL6180x_PLATFORM_PROVIDE_SQRT
/*
* 32 bit integer square root with not so bad precision (integer result) and is quite fast
... | code_fim | hard | {
"lang": "rust",
"repo": "burrbull/vl6180x",
"path": "/src/dmax_ranging.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> minSignalNeeded = (RegB8 * 256) / ((int32_t)MaxConvTime + (int32_t)MaxConvTimeAdjust);
/* KCps 8+8 bit -(1 to 6 bit) => 15-10 bit */
/* minSignalNeeded = max ( minSignalNeeded, RangeIgnoreThreshold - XTalkCompRate_KCps) */
if (minSignalNeeded <= (int32_t)RangeIgnoreThreshold - (int32_t)X... | code_fim | hard | {
"lang": "rust",
"repo": "burrbull/vl6180x",
"path": "/src/dmax_ranging.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let snrLimit = self.read(i2c, pac::SYSRANGE_MAX_AMBIENT_LEVEL_MULT).bits();
_DMaxData(snrLimit_K) = 16_i32 * 1000 / snrLimit;
XTalkCompRate_KCps = self.dev.XTalkCompRate_KCps);
if (Reg2A_KCps >= XTalkCompRate_KCps) {
_DMaxData(retSignalAt400mm) = Reg2A_KCps;
} else{
... | code_fim | hard | {
"lang": "rust",
"repo": "burrbull/vl6180x",
"path": "/src/dmax_ranging.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn poll(
&mut self,
_cx: &mut Context,
_params: &mut impl PollParameters,
) -> Poll<NetworkBehaviourAction<void::Void, void::Void>> {
Poll::Pending
}
fn inject_connection_established(
&mut self,
peer_id: &PeerId,
_: &ConnectionId,
... | code_fim | hard | {
"lang": "rust",
"repo": "dvc94ch/ipfs-embed",
"path": "/net/src/peers.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.