text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: s0l0ist/rust-ckks path: /src/ckks/encoder.rs
.n {
// For each row we select a different root
// root = xi ^ (2i + 1)
let root = xi.powu((2 * i as u32) + 1);
// Then we store its powers
for j in 0..n {
// ans = root ^ j
... | code_fim | hard | {
"lang": "rust",
"repo": "s0l0ist/rust-ckks",
"path": "/src/ckks/encoder.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let vect = DMatrix::from_vec(
NUM_ROWS,
NUM_COLS,
vec![
Complex64::new(192.0, 256.0),
Complex64::new(128.0, -64.0),
Complex64::new(128.0, 64.0),
Complex64::new(192.0, -256.0),
],
... | code_fim | hard | {
"lang": "rust",
"repo": "s0l0ist/rust-ckks",
"path": "/src/ckks/encoder.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: will-hart/ld48 path: /src/main.rs
// disable console on windows for release builds
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
#[cfg(target_arch = "wasm32")]
use bevy_webgl2;
use bevy::{
prelude::*,
render::{pipeline::PipelineDescriptor, pipeline::RenderPipeline,... | code_fim | hard | {
"lang": "rust",
"repo": "will-hart/ld48",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // create a custom shader pipeline for the world sprite
#[cfg(target_arch = "wasm32")]
let pipeline_handle = pipelines.add(sf_core::render::render_pipeline_web::get_custom_pipeline(
&mut shaders,
));
#[cfg(not(target_arch = "wasm32"))]
let pipeline_handle = pipelines.add(s... | code_fim | hard | {
"lang": "rust",
"repo": "will-hart/ld48",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fengalin/media-toc path: /ui/src/info/controller.rs
es =
toc_extensions
.into_iter()
.filter_map(|(extension, format)| {
let path = info
.path
.with_file_name(f... | code_fim | hard | {
"lang": "rust",
"repo": "fengalin/media-toc",
"path": "/ui/src/info/controller.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut position_status = self.chapter_manager.update_ts(ts);
if self.repeat_chapter {
// repeat is activated
if state.is_eos() {
// postpone chapter selection change until media has synchronized
position_status = PositionStatus::Cha... | code_fim | hard | {
"lang": "rust",
"repo": "fengalin/media-toc",
"path": "/ui/src/info/controller.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn repeat_at(&self, ts: Timestamp) {
playback::seek(ts, gst::SeekFlags::ACCURATE)
}
pub fn tick(&mut self, ts: Timestamp, state: main_panel::State) {
self.timeline_scale.set_value(ts.as_f64());
let mut position_status = self.chapter_manager.update_ts(ts);
if ... | code_fim | hard | {
"lang": "rust",
"repo": "fengalin/media-toc",
"path": "/ui/src/info/controller.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ign(x, k);
}
val
} else {
T::zero()
}
}
/// Evaluate a polynomial of rank known at compile-time using Horner's method.
///
/// For now this function simply calls [eval_any_rank_polynomial], but the idea
/// is that in the future we may be able to optimize our code further in the case
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "ctsrc/horner",
"path": "/src/lib.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ctsrc/horner path: /src/lib.rs
use num_traits::ops::mul_add::MulAddAssign;
use num_traits::Zero;
/// Evaluate a polynomial of arbitrary rank using Horner's method.
///
/// Horner's method goes like this: to find 𝑎𝑥³+𝑏𝑥²+𝑐𝑥+𝑑, you evaluate 𝑥(𝑥(𝑎𝑥+𝑏)+𝑐)+𝑑.
///
/// That's what this f... | code_fim | hard | {
"lang": "rust",
"repo": "ctsrc/horner",
"path": "/src/lib.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
#![allow(unused)]
/// Tests whether [`Done`] is actually [`Done`] when inside the first argument to [`Call`].
#[test]
fn done_in_seq() {
use crate::prelude::*;
use crate::types::*;
type S = Session! {
loop {
cal... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/dialectic",
"path": "/dialectic/src/types/done.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use crate::prelude::*;
use crate::types::*;
type S = Session! {
loop {
call {
send String;
}
recv String;
break;
}
};
async fn serve<Tx, Rx>(chan: Chan<S, T... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/dialectic",
"path": "/dialectic/src/types/done.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/dialectic path: /dialectic/src/types/done.rs
use super::sealed::IsSession;
use super::*;
/// A finished session. The only thing to do with a [`Chan`](crate::Chan) when it is `Done` is to
/// drop it or, preferably, [`close`](crate::Chan::close) it.
#[derive(Debug, Clone, Copy, PartialEq... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/dialectic",
"path": "/dialectic/src/types/done.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod query;
pub mod source;
pub mod getters;
pub mod order_by;
pub mod filter;
pub mod setters;
pub mod builders;
pub use self::{
utils::{Seq},
query::{Row, TypedRow, IntoSql, SqlInput},
query::synchronous, // query::asynchronous,
source::{Source, Column},
getters::{Selection, Retu... | code_fim | medium | {
"lang": "rust",
"repo": "rmanoka/tygres",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rmanoka/tygres path: /src/lib.rs
#![feature(associated_type_defaults)]
#[macro_use]
pub mod macros;
<|fim_suffix|>pub use self::{
utils::{Seq},
query::{Row, TypedRow, IntoSql, SqlInput},
query::synchronous, // query::asynchronous,
source::{Source, Column},
getters::{Selecti... | code_fim | medium | {
"lang": "rust",
"repo": "rmanoka/tygres",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::{
utils::{Seq},
query::{Row, TypedRow, IntoSql, SqlInput},
query::synchronous, // query::asynchronous,
source::{Source, Column},
getters::{Selection, ReturningClause, Makes, OptionalSelection, Getter},
filter::{Clause, WhereClause, Equality},
setters::{ColumnsSett... | code_fim | medium | {
"lang": "rust",
"repo": "rmanoka/tygres",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: taisukef/deno path: /cli/doc/mod.rs
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
pub mod class;
pub mod r#enum;
pub mod function;
pub mod interface;
pub mod module;
pub mod namespace;
mod node;
pub mod params;
pub mod parser;
pub mod printer;
pub mod ts_type;
pub mo... | code_fim | medium | {
"lang": "rust",
"repo": "taisukef/deno",
"path": "/cli/doc/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn find_node_by_name_recursively(
doc_nodes: Vec<DocNode>,
name: String,
) -> Option<DocNode> {
let mut parts = name.splitn(2, '.');
let name = parts.next();
let leftover = parts.next();
name?;
let node = find_node_by_name(doc_nodes, name.unwrap().to_string());
match node {
Some(no... | code_fim | medium | {
"lang": "rust",
"repo": "taisukef/deno",
"path": "/cli/doc/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jhungerford/adventofcode-2019 path: /day7/src/main.rs
use itertools::Itertools;
use rayon::prelude::*;
use crate::computer::Computer;
/// Runs the program on a series of amplifiers, using the given phase settings and passing the output from one amp to the next.
fn chain_output(computer: &Compu... | code_fim | hard | {
"lang": "rust",
"repo": "jhungerford/adventofcode-2019",
"path": "/day7/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Given a program, returns the maximum output that a looped chain of amplifiers can produce.
fn max_looped_output(computer: &Computer) -> i32 {
let phase_settings = vec![5, 6, 7, 8, 9];
phase_settings.into_iter()
.permutations(5)
.par_bridge()
.map(|permutation| looped_o... | code_fim | hard | {
"lang": "rust",
"repo": "jhungerford/adventofcode-2019",
"path": "/day7/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
amplifiers[i].input(value);
if !amplifiers[i].is_runnable() {
break;
}
value = amplifiers[i].run().unwrap();
i = (i + 1) % 5;
}
// Output comes from the last amplifier.
amplifiers[4].last_output().unwrap()
}
/// Given a program... | code_fim | hard | {
"lang": "rust",
"repo": "jhungerford/adventofcode-2019",
"path": "/day7/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: baby636/diem path: /language/move-lang/src/expansion/address_map.rs
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{
parser::ast::{self as P},
shared::{unique_map::UniqueMap, *},
FullyCompiledProgram,
};
use move_ir_types::location::*;
... | code_fim | hard | {
"lang": "rust",
"repo": "baby636/diem",
"path": "/language/move-lang/src/expansion/address_map.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // If the address was previously just a name, bind the declaration, whatever it is
(Some(None), addr_value_opt) => {
context.map.remove(name);
context.map.add(name.clone(), *addr_value_opt).unwrap()
}
// If the address was assigned a value, and now ... | code_fim | hard | {
"lang": "rust",
"repo": "baby636/diem",
"path": "/language/move-lang/src/expansion/address_map.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-analyzer/rowan path: /src/ast.rs
//! Working with abstract syntax trees.
//!
//! In rowan, syntax trees are transient objects. That means that we create
//! trees when we need them, and tear them down to save memory. In this
//! architecture, hanging on to a particular syntax node for a lon... | code_fim | hard | {
"lang": "rust",
"repo": "rust-analyzer/rowan",
"path": "/src/ast.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.raw.hash(state)
}
}
impl<N: AstNode> From<AstPtr<N>> for SyntaxNodePtr<N::Language> {
fn from(ptr: AstPtr<N>) -> SyntaxNodePtr<N::Language> {
ptr.raw
}
}
#[derive(Debug, Clone)]
pub struct AstChildren<N: AstNode> {
inner: SyntaxNodeChildren<N::Language>,
ph: Phan... | code_fim | hard | {
"lang": "rust",
"repo": "rust-analyzer/rowan",
"path": "/src/ast.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pop.evaluate();
println!("Generation : 0");
println!("Max : {}", pop.max().rank);
println!("Min : {}", pop.min().rank);
println!("-----------------------------");
for gen in 1..generation {
pop.evolution();
println!("Generation ... | code_fim | hard | {
"lang": "rust",
"repo": "ksk001100/onemax",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut pop = Population::new(gene_length, individual_length, mutate_rate, elite_rate);
pop.evaluate();
println!("Generation : 0");
println!("Max : {}", pop.max().rank);
println!("Min : {}", pop.min().rank);
println!("----------------------------... | code_fim | hard | {
"lang": "rust",
"repo": "ksk001100/onemax",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ksk001100/onemax path: /src/main.rs
mod ga;
use ga::*;
use seahorse::*;
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
let app = App::new(env!("CARGO_PKG_NAME"))
.author(env!("CARGO_PKG_AUTHORS"))
.description(env!("CARGO_PKG_DESCRIPTION"))
... | code_fim | hard | {
"lang": "rust",
"repo": "ksk001100/onemax",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LukeMathWalker/build-your-own-jira-with-rust path: /jira-cli/src/models/title.rs
use serde::{Deserialize, Serialize};
use std::error::Error;
use std::fmt;
use std::fmt::Formatter;
#[derive(PartialEq, Debug, Clone, Hash, Eq, Serialize, Deserialize)]
/// The title of a [Ticket](Ticket)
/// Wraps ... | code_fim | hard | {
"lang": "rust",
"repo": "LukeMathWalker/build-your-own-jira-with-rust",
"path": "/jira-cli/src/models/title.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for TitleError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.details)
}
}
impl Error for TitleError {
fn description(&self) -> &str {
&self.details
}
}
impl Title {
/// Creates a Title for a [Ticket](Ticket)
/// re... | code_fim | medium | {
"lang": "rust",
"repo": "LukeMathWalker/build-your-own-jira-with-rust",
"path": "/jira-cli/src/models/title.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !out.status.success() {
panic!("{:?}", unsafe {
core::str::from_utf8_unchecked(&out.stdout)
});
}
}<|fim_prefix|>// repo: sclolus/Turbofish path: /rust_kernel/dependencies/libc_binding/build.rs
use std::process::Command;
fn main() {
<|fim_middle|> println!(r#"ca... | code_fim | hard | {
"lang": "rust",
"repo": "sclolus/Turbofish",
"path": "/rust_kernel/dependencies/libc_binding/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sclolus/Turbofish path: /rust_kernel/dependencies/libc_binding/build.rs
use std::process::Command;
fn main() {
<|fim_suffix|> if !out.status.success() {
panic!("{:?}", unsafe {
core::str::from_utf8_unchecked(&out.stdout)
});
}
}<|fim_middle|> println!(r#"ca... | code_fim | hard | {
"lang": "rust",
"repo": "sclolus/Turbofish",
"path": "/rust_kernel/dependencies/libc_binding/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (sender1, receiver1) = oneshot::channel::<Result<Image, JsValue>>();
let (sender2, receiver2) = oneshot::channel::<Result<Image, JsValue>>();
let (sender3, receiver3) = oneshot::channel::<Result<Image, JsValue>>();
let (sender4, receiver4) = oneshot::channel::<Result<Image, JsValue>>()... | code_fim | hard | {
"lang": "rust",
"repo": "Mubelotix/tetris",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let images = join!(loading_tracker_future, image1_future, image2_future, image3_future, image4_future, image5_future, image6_future, image7_future, image8_future).0;
let font = Font::load("font.ttf").await.unwrap();
let mut grid = Grid {
textures: [&images[0], &images[1], &images[2]... | code_fim | hard | {
"lang": "rust",
"repo": "Mubelotix/tetris",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mubelotix/tetris path: /src/lib.rs
#[allow(unused_imports)]
use wasm_bindgen::{prelude::*, JsCast};
use wasm_game_lib::graphics::image::Image;
use wasm_game_lib::graphics::sprite::Sprite;
use wasm_game_lib::graphics::font::Font;
use wasm_game_lib::graphics::text::Text;
use wasm_game_lib::inputs... | code_fim | hard | {
"lang": "rust",
"repo": "Mubelotix/tetris",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: togglebyte/netlib path: /src/connections.rs
use std::ops::{IndexMut, Index};
#[derive(Debug)]
pub struct Connections<T> {
inner: Vec<Option<T>>,
free_slots: Vec<usize>,
}
impl<T> Connections<T> {
pub fn with_capacity(capacity: usize) -> Self {
// let inner = (0..capacity).... | code_fim | hard | {
"lang": "rust",
"repo": "togglebyte/netlib",
"path": "/src/connections.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match &self.inner[index] {
Some(ref val) => val,
None => panic!(),
}
}
}
impl<T> IndexMut<usize> for Connections<T> {
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
match &mut self.inner[index] {
Some(ref mut val) => val,
... | code_fim | medium | {
"lang": "rust",
"repo": "togglebyte/netlib",
"path": "/src/connections.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: icedland/iced path: /src/rust/iced-x86/src/test/instr_misc.rs
mediate8_2nd(u8::MAX);
assert_eq!(instr.immediate8_2nd(), u8::MAX);
instr.set_immediate16(u16::MIN);
assert_eq!(instr.immediate16(), u16::MIN);
instr.set_immediate16(u16::MAX);
assert_eq!(instr.immediate16(), u16::MAX);
instr.... | code_fim | hard | {
"lang": "rust",
"repo": "icedland/iced",
"path": "/src/rust/iced-x86/src/test/instr_misc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: icedland/iced path: /src/rust/iced-x86/src/test/instr_misc.rs
lacement32(), u32::MAX);
assert_eq!(instr.memory_displacement64(), u64::MAX);
instr.set_memory_displacement64(0x1234_5678_9ABC_DEF1);
instr.set_memory_displacement32(0x5AA5_4321);
assert_eq!(instr.memory_displacement32(), 0x5AA5_... | code_fim | hard | {
"lang": "rust",
"repo": "icedland/iced",
"path": "/src/rust/iced-x86/src/test/instr_misc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for reg in Register::values() {
instr.set_op3_register(reg);
assert_eq!(instr.op3_register(), reg);
}
for reg in Register::values() {
if reg == Register::None {
instr.set_op4_register(reg);
instr.try_set_op4_register(reg).unwrap();
assert_eq!(instr.op4_register(), reg);
} else {
as... | code_fim | hard | {
"lang": "rust",
"repo": "icedland/iced",
"path": "/src/rust/iced-x86/src/test/instr_misc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: peakchen90/json-parser-rust path: /tiny-json/src/node.rs
use std::fmt::{Display, Formatter};
use std::ops::Deref;
use crate::parser::Parser;
use crate::token::TokenType;
pub enum NodeType {
Root,
ObjectExpression,
ObjectProperty,
ArrayExpression,
StringLiteral,
NumericLi... | code_fim | hard | {
"lang": "rust",
"repo": "peakchen90/json-parser-rust",
"path": "/tiny-json/src/node.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_children_as_value(&self) -> &String {
match self.children.deref() {
NodeChild::Value(x) => x,
_ => panic!("Invalid visit children of Node")
}
}
pub fn get_children_as_list(&self) -> &Vec<Node> {
match self.children.deref() {
... | code_fim | hard | {
"lang": "rust",
"repo": "peakchen90/json-parser-rust",
"path": "/tiny-json/src/node.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Healer-fuzz/healer-fuzz path: /src/fuzz/features.rs
use iota::iota;
use crate::{
exec::syz::SyzExecHandle,
vm::{qemu::QemuHandle, ManageVm},
};
iota! {
pub const FEATURE_COVERAGE: u64 = 1 << (iota);
,FEATURE_COMPARISONS
,FEATURE_EXTRA_COVERAGE
,FEATURE_SANDBOX_SETUID
... | code_fim | hard | {
"lang": "rust",
"repo": "Healer-fuzz/healer-fuzz",
"path": "/src/fuzz/features.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> emulation",
];
let features = handle
.features
.unwrap_or(FEATURE_COVERAGE | FEATURE_SANDBOX_SETUID | FEATURE_NET_DEVICES);
if verbose {
for (i, feature) in FEATURES.iter().enumerate() {
if features & (1 << i) != 0 {
log::info!("{:<28}: enab... | code_fim | hard | {
"lang": "rust",
"repo": "Healer-fuzz/healer-fuzz",
"path": "/src/fuzz/features.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn DADissenterGetStatusString(
dissenter: DADissenterRef,
) -> cf::string::CFStringRef;
}<|fim_prefix|>// repo: ParkMyCar/disk-arbitration path: /src/dissenter.rs
#![deny(missing_debug_implementations)]
use core_foundation as cf;
use libc::{
c_int,
c_void,
};
#[derive(Debug)... | code_fim | hard | {
"lang": "rust",
"repo": "ParkMyCar/disk-arbitration",
"path": "/src/dissenter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ParkMyCar/disk-arbitration path: /src/dissenter.rs
#![deny(missing_debug_implementations)]
use core_foundation as cf;
use libc::{
c_int,
c_void,
};
#[derive(Debug)]
#[repr(C)]
pub struct _DADissenter(c_void);
pub type DADissenterRef = *const _DADissenter;
<|fim_suffix|> pub fn DADi... | code_fim | hard | {
"lang": "rust",
"repo": "ParkMyCar/disk-arbitration",
"path": "/src/dissenter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut sum = (rounds as u32).wrapping_mul(0x9e3779b9);
let mut y = block[0];
for _ in 0..rounds {
// cycle
let e = sum >> 2;
for r in (0..block.len()).rev() {
// round
let z = block[(r + block.len() - 1) % block.len()];
block[r] = bl... | code_fim | hard | {
"lang": "rust",
"repo": "mgottschlag/xxtea-nostd",
"path": "/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mgottschlag/xxtea-nostd path: /src/lib.rs
#![no_std]
#[cfg(test)]
#[macro_use]
extern crate std;
use core::slice;
// The code is based on the public domain implementation at
// https://github.com/mycelium-com/entropy/blob/master/lib/xxtea.c
fn as_u32_slice<'a>(x: &'a [u8]) -> &'a [u32] {
... | code_fim | hard | {
"lang": "rust",
"repo": "mgottschlag/xxtea-nostd",
"path": "/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_vectors() {
const TEST_VECTORS: [(&str, &str, &str); 20] = [
(
"00000000000000000000000000000000",
"0000000000000000",
"ab043705808c5d57",
),
(
"0102040810204080fffefcf8f0e0c... | code_fim | hard | {
"lang": "rust",
"repo": "mgottschlag/xxtea-nostd",
"path": "/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> while self.pc >= 0 && self.pc < opcodes.len() as i64 {
match &opcodes[self.pc as usize] {
OpCode::Snd(val) => {
let x = match val {
Value::Int(i) => i,
Value::Reg(ch) => self.regs.get(&ch).unwrap_or(&0)... | code_fim | hard | {
"lang": "rust",
"repo": "jasilven/aoc-2017-rust",
"path": "/src/bin/day18.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jasilven/aoc-2017-rust path: /src/bin/day18.rs
use std::collections::HashMap;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::sync::mpsc;
use std::sync::mpsc::{Receiver, Sender};
use std::thread;
use std::time::Duration;
#[derive(Debug, Clone)]
enum Value {
Int(i64),
Reg(... | code_fim | hard | {
"lang": "rust",
"repo": "jasilven/aoc-2017-rust",
"path": "/src/bin/day18.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let file = File::open(fname)?;
let reader = BufReader::new(file);
let mut result = Vec::new();
for line in reader.lines() {
let line = line?;
let mut splits = line.split(' ');
match splits.next() {
Some("snd") => result.push(OpCode::Snd(Value::from(spl... | code_fim | hard | {
"lang": "rust",
"repo": "jasilven/aoc-2017-rust",
"path": "/src/bin/day18.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn time_to_live(&self) -> u8 {
self.header[8]
}
pub fn set_time_to_live(&mut self, ttl: u8) {
self.header[8] = ttl;
}
pub fn protocol(&self) -> IpProtocol {
match self.header[9] {
0x01 => IpProtocol::ICMP,
0x06 => IpProtocol::TCP,
... | code_fim | hard | {
"lang": "rust",
"repo": "varesa/rs-network-stack",
"path": "/src/protocols/ipv4.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: varesa/rs-network-stack path: /src/protocols/ipv4.rs
use std::convert::TryInto;
use std::fmt;
use byteorder::{NetworkEndian, ReadBytesExt, WriteBytesExt};
use std::fmt::{Formatter, Debug};
use crate::protocols::icmp::IcmpPacket;
use std::mem::take;
use internet_checksum::Checksum;
// Custom fmt... | code_fim | hard | {
"lang": "rust",
"repo": "varesa/rs-network-stack",
"path": "/src/protocols/ipv4.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> From<&'a mut [u8]> for Ipv4Header<'a> {
fn from(buffer: &'a mut [u8]) -> Self {
let ihl = buffer[0] & 0x0F;
let (header, rest) = buffer.split_at_mut(12);
let (source_ip_bytes, rest) = rest.split_at_mut(4);
let (destination_ip_bytes, rest) = rest.split_at_mut(4... | code_fim | hard | {
"lang": "rust",
"repo": "varesa/rs-network-stack",
"path": "/src/protocols/ipv4.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mikelma/nbkit path: /src/lib/lib.rs
#[macro_use]
extern crate clap;
use semver::VersionReq;
<|fim_suffix|>// declare constants
pub const DEFAULT_SET: core::Set = core::Set::Universe;<|fim_middle|>use std::error::Error;
pub mod core;
pub mod nbpm;
pub mod repo;
pub mod utils;
// custom types
... | code_fim | hard | {
"lang": "rust",
"repo": "mikelma/nbkit",
"path": "/src/lib/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mikelma/nbkit path: /src/lib/lib.rs
#[macro_use]
extern crate clap;
use semver::VersionReq;
use std::error::Error;
<|fim_suffix|>// custom types
pub type TypeErr = Box<dyn Error>;
pub type Query = (String, VersionReq);
pub type Dependencies = Option<Vec<Query>>;
// declare constants
pub cons... | code_fim | easy | {
"lang": "rust",
"repo": "mikelma/nbkit",
"path": "/src/lib/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// custom types
pub type TypeErr = Box<dyn Error>;
pub type Query = (String, VersionReq);
pub type Dependencies = Option<Vec<Query>>;
// declare constants
pub const DEFAULT_SET: core::Set = core::Set::Universe;<|fim_prefix|>// repo: mikelma/nbkit path: /src/lib/lib.rs
#[macro_use]
extern crate clap;
us... | code_fim | medium | {
"lang": "rust",
"repo": "mikelma/nbkit",
"path": "/src/lib/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> gpiod.bsrr.write(|w| w.br12().reset());
gpiod.bsrr.write(|w| w.br13().reset());
gpiod.bsrr.write(|w| w.br14().reset());
gpiod.bsrr.write(|w| w.br15().reset());
delay(8_000_000);
}
}<|fim_prefix|>// repo: ashtkn/learning-rust-language path: /embedded_system/src... | code_fim | hard | {
"lang": "rust",
"repo": "ashtkn/learning-rust-language",
"path": "/embedded_system/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ashtkn/learning-rust-language path: /embedded_system/src/main.rs
#![no_std]
#![no_main]
extern crate panic_halt;
use cortex_m::asm::delay;
use cortex_m_rt::entry;
use stm32f4::stm32f407;
<|fim_suffix|> delay(8_000_000);
gpiod.bsrr.write(|w| w.br12().reset());
gpiod.bsr... | code_fim | hard | {
"lang": "rust",
"repo": "ashtkn/learning-rust-language",
"path": "/embedded_system/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> delay(8_000_000);
gpiod.bsrr.write(|w| w.br12().reset());
gpiod.bsrr.write(|w| w.br13().reset());
gpiod.bsrr.write(|w| w.br14().reset());
gpiod.bsrr.write(|w| w.br15().reset());
delay(8_000_000);
}
}<|fim_prefix|>// repo: ashtkn/learning-rust-language ... | code_fim | hard | {
"lang": "rust",
"repo": "ashtkn/learning-rust-language",
"path": "/embedded_system/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jackpeters667/iced_examples path: /examples/random_accel.rs
use rand::prelude::*;
use iced::{Application,
executor,
time,
Command,
Element,
Canvas,
Length,
canvas,
Color,
Settings,
... | code_fim | hard | {
"lang": "rust",
"repo": "jackpeters667/iced_examples",
"path": "/examples/random_accel.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
Canvas::new(self)
.width(Length::Fill)
.height(Length::Fill)
.into()
}
}
#[derive(Debug)]
struct Circulo {
radius: f32,
center: Point,
velocity: Vector,
accel: Vector,
}
impl Circulo {
pub fn new(posicion: Point, velocidad: Vector, a... | code_fim | hard | {
"lang": "rust",
"repo": "jackpeters667/iced_examples",
"path": "/examples/random_accel.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Set the collision object shape.
#[inline]
pub fn set_shape(&mut self, shape: ShapeHandle<N>) {
self.update_flags |= CollisionObjectUpdateFlags::SHAPE_CHANGED;
self.shape = shape
}
/// The collision groups of the collision object.
#[inline]
pub fn collision_... | code_fim | hard | {
"lang": "rust",
"repo": "dimforge/ncollide",
"path": "/src/pipeline/object/collision_object.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dimforge/ncollide path: /src/pipeline/object/collision_object.rs
use crate::bounding_volume::{self, BoundingVolume, AABB};
use crate::math::Isometry;
use crate::pipeline::broad_phase::BroadPhaseProxyHandle;
use crate::pipeline::narrow_phase::CollisionObjectGraphIndex;
use crate::pipeline::object... | code_fim | hard | {
"lang": "rust",
"repo": "dimforge/ncollide",
"path": "/src/pipeline/object/collision_object.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vmware-archive/haret path: /haret/src/vr/states/do_view_change.rs
// Copyright © 2016-2017 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use std::convert::{From, Into};
use rabble::{self, Pid, CorrelationId, Envelope};
use time::SteadyTime;
use msg::Msg;
use vr::vr_fs... | code_fim | hard | {
"lang": "rust",
"repo": "vmware-archive/haret",
"path": "/haret/src/vr/states/do_view_change.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let current = Latest {
last_normal_view: self.ctx.last_normal_view,
commit_num: self.ctx.commit_num,
op: self.ctx.op,
log_start: self.ctx.global_min_accept,
log_tail: self.ctx.get_log_tail()
};
self.responses.drain()
... | code_fim | hard | {
"lang": "rust",
"repo": "vmware-archive/haret",
"path": "/haret/src/vr/states/do_view_change.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: techtheriac/RustInMotion path: /src/main.rs
use std::io;
fn main() {
match_that_hoe(89);
}
// Conditionals
fn _this_or_that() {
let a = true;
let b = false;
let c : f64 = 89.9;
let d = 'c';
// Simple tuple
let tup = (d, c, a);
// Tuple values accesse... | code_fim | hard | {
"lang": "rust",
"repo": "techtheriac/RustInMotion",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Looping
fn _right_word() {
loop{
println!("What is the secret word?");
let mut word = String::new();
io::stdin().read_line(&mut word).expect("Failed to read line");
if word.trim() == "rust" {
break;
}
}
println!("You know the secret wor... | code_fim | hard | {
"lang": "rust",
"repo": "techtheriac/RustInMotion",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if tup.2 {
println!("You just messed with a tuple with the corresponding values {} {} {}", first, second, tup.2);
}
}
fn _slice_that_hoe() {
// Array elements are of the same type
// They are of fixed sized upon initialization
let _new_array = [1.01, 2.2, 99.90];
// ... | code_fim | hard | {
"lang": "rust",
"repo": "techtheriac/RustInMotion",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(sues[0].index)
}
fn part2(input: String) -> Result<usize> {
let mut sues: Vec<Sue> = input.lines().map(parse_line).collect::<Result<_>>()?;
sues.retain(|sue| {
for &(key, value) in KNOWN_PROPS.iter() {
if let Some(&sue_value) = sue.properties.get(key) {
... | code_fim | hard | {
"lang": "rust",
"repo": "Aidiakapi/advent_of_code_2015",
"path": "/src/day16.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Aidiakapi/advent_of_code_2015 path: /src/day16.rs
day!(
day16,
"https://adventofcode.com/2015/day/16/input",
part1,
part2
);
use regex::Regex;
use std::collections::HashMap;
#[derive(Debug, Clone, Eq, PartialEq)]
struct Sue {
index: usize,
properties: HashMap<String, us... | code_fim | hard | {
"lang": "rust",
"repo": "Aidiakapi/advent_of_code_2015",
"path": "/src/day16.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = lib::read_input_file().unwrap();
let input = input.trim();
println!("{}",solve(input, false));
println!("{}",solve(input, true));
}<|fim_prefix|>// repo: mookid/rust-adventofcode2017 path: /src/day4-high-entropy-passphrases.rs
mod lib;
fn solve(input: &str, filter_anagrams: b... | code_fim | medium | {
"lang": "rust",
"repo": "mookid/rust-adventofcode2017",
"path": "/src/day4-high-entropy-passphrases.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mookid/rust-adventofcode2017 path: /src/day4-high-entropy-passphrases.rs
mod lib;
fn solve(input: &str, filter_anagrams: bool) -> usize {
input.lines().filter(|line| {
let mut toks = line.split(char::is_whitespace)
.map(String::from)
.collect::<Vec<_>>();
... | code_fim | medium | {
"lang": "rust",
"repo": "mookid/rust-adventofcode2017",
"path": "/src/day4-high-entropy-passphrases.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cholcombe973/isilon path: /src/models/zone.rs
/// Zone : Specifies properties for access zones.
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct Zone {
/// Specifies an alternate system provider.
#[serde(rename = "alternate_system_prov... | code_fim | hard | {
"lang": "rust",
"repo": "cholcombe973/isilon",
"path": "/src/models/zone.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>etbios_name: Option<String>,
/// Specifies the access zone base directory path.
#[serde(rename = "path")]
pub path: Option<String>,
/// Specifies the skeleton directory that is used for user home directories.
#[serde(rename = "skeleton_directory")]
pub skeleton_directory: Option<St... | code_fim | hard | {
"lang": "rust",
"repo": "cholcombe973/isilon",
"path": "/src/models/zone.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub ifs_restricted: Option<Vec <crate::models::AuthAccessAccessItemFileGroup>>,
/// Maps untrusted domains to this NetBIOS domain during authentication.
#[serde(rename = "map_untrusted")]
pub map_untrusted: Option<String>,
/// Specifies the access zone name.
#[serde(rename = "name")... | code_fim | hard | {
"lang": "rust",
"repo": "cholcombe973/isilon",
"path": "/src/models/zone.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let request_body = RequestBody {
id: self.permission_client.permission_name().name(),
permission_mode,
resource: resource.uri(),
};
let request_body = serde_json::to_string(&request_body)?;
let req = req.body(hyper::Body::from(request_bo... | code_fim | hard | {
"lang": "rust",
"repo": "guywaldman/AzureSDKForRust",
"path": "/azure_sdk_cosmos/src/requests/create_permission_builder.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: guywaldman/AzureSDKForRust path: /azure_sdk_cosmos/src/requests/create_permission_builder.rs
use crate::clients::{CosmosUriBuilder, PermissionClient, ResourceType};
use crate::prelude::*;
use crate::responses::CreatePermissionResponse;
use crate::{PermissionMode, PermissionResource};
use azure_s... | code_fim | hard | {
"lang": "rust",
"repo": "guywaldman/AzureSDKForRust",
"path": "/azure_sdk_cosmos/src/requests/create_permission_builder.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn handle_embedded_file(path: &str) -> HttpResponse {
let path = format!("dist/{}", path);
match Asset::get(&path) {
Some(content) => {
let body: Body = match content {
Cow::Borrowed(bytes) => bytes.into(),
Cow::Owned(bytes) => bytes.into(),
... | code_fim | medium | {
"lang": "rust",
"repo": "markrepedersen/switcharoo",
"path": "/src/routes/web.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let path = format!("dist/{}", path);
match Asset::get(&path) {
Some(content) => {
let body: Body = match content {
Cow::Borrowed(bytes) => bytes.into(),
Cow::Owned(bytes) => bytes.into(),
};
HttpResponse::Ok()
... | code_fim | medium | {
"lang": "rust",
"repo": "markrepedersen/switcharoo",
"path": "/src/routes/web.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: markrepedersen/switcharoo path: /src/routes/web.rs
use actix_web::{body::Body, dev::ResourcePath, web::Path};
use actix_web::{get, HttpResponse};
use mime_guess::from_path;
use rust_embed::RustEmbed;
use std::borrow::Cow;
#[derive(RustEmbed)]
#[folder = "web/"]
struct Asset;
<|fim_suffix|> ... | code_fim | medium | {
"lang": "rust",
"repo": "markrepedersen/switcharoo",
"path": "/src/routes/web.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lassade/bevy_gizmos path: /src/render_graph/mod.rs
use bevy::{
prelude::*,
reflect::TypeUuid,
render::{
pipeline::*,
render_graph::{base, RenderGraph, RenderResourcesNode},
shader::{Shader, ShaderStage, ShaderStages},
texture::TextureFormat,
},
};
... | code_fim | hard | {
"lang": "rust",
"repo": "lassade/bevy_gizmos",
"path": "/src/render_graph/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> render_graph.add_system_node(
"gizmo_material",
RenderResourcesNode::<GizmoMaterial>::new(true),
);
render_graph
.add_node_edge("gizmo_material", base::node::MAIN_PASS)
.unwrap();
render_graph.add_system_node(
screen_info_node::SCREEN_INFO_NODE,
... | code_fim | hard | {
"lang": "rust",
"repo": "lassade/bevy_gizmos",
"path": "/src/render_graph/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pipelines.set_untracked(GIZMOS_PIPELINE_HANDLE, gizmo_pipeline);
render_graph.add_system_node(
"gizmo_material",
RenderResourcesNode::<GizmoMaterial>::new(true),
);
render_graph
.add_node_edge("gizmo_material", base::node::MAIN_PASS)
.unwrap();
render_... | code_fim | hard | {
"lang": "rust",
"repo": "lassade/bevy_gizmos",
"path": "/src/render_graph/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: whbeers/moisture-preempt path: /src/main.rs
//! simple program to blink an LED at a rate that changes based on ADC
//! readings from a moisture sensor.
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
use stm32f1xx_hal::{
adc,
gpio,
prelude::*,
timer::{Event, Ti... | code_fim | hard | {
"lang": "rust",
"repo": "whbeers/moisture-preempt",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> cx.resources.sensor_rate_timer.clear_update_interrupt_flag();
cx.resources.sensor_rate_timer.start(ADC_RATE.hz());
}
// TODO(whbeers): implement wifi interface
// requirements:
// - pull CHIP_EN high using a digital GPIO to turn on esp8266
// - configure a USART or S... | code_fim | hard | {
"lang": "rust",
"repo": "whbeers/moisture-preempt",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: overminder/sanya-jit path: /src/scheme/src/rt/gc/mod.rs
mod naive_copying;
mod generational;
pub <|fim_suffix|>Args};
pub const INFO_FRESH_TAG: usize = 0;
pub const INFO_MARKED_TAG: usize = 1;<|fim_middle|>use self::naive_copying::{GcState, FullGc | code_fim | easy | {
"lang": "rust",
"repo": "overminder/sanya-jit",
"path": "/src/scheme/src/rt/gc/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 0;
pub const INFO_MARKED_TAG: usize = 1;<|fim_prefix|>// repo: overminder/sanya-jit path: /src/scheme/src/rt/gc/mod.rs
mod naive_copying;
mod generational;
pub <|fim_middle|>use self::naive_copying::{GcState, FullGcArgs};
pub const INFO_FRESH_TAG: usize = | code_fim | medium | {
"lang": "rust",
"repo": "overminder/sanya-jit",
"path": "/src/scheme/src/rt/gc/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[wasm_bindgen(module = "electron")]
extern {
#[wasm_bindgen]
pub type BrowserWindow;
/// Cannot call this method if running untrusted content
/// since it requires following BrowserWindow settings:
///
/// ```js
/// webPreferences: {
/// nodeIntegration: true,
/// ... | code_fim | hard | {
"lang": "rust",
"repo": "x7c1/barley",
"path": "/project-rs/app-renderer/src/js.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: x7c1/barley path: /project-rs/app-renderer/src/js.rs
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern {
#[wasm_bindgen]
pub type Console;
pub static console: Console;
#[wasm_bindgen(method)]
pub fn log(this: &Console, s: &str);
}
#[wasm_bindgen]
extern {
#[wasm_bi... | code_fim | hard | {
"lang": "rust",
"repo": "x7c1/barley",
"path": "/project-rs/app-renderer/src/js.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[wasm_bindgen(method, js_name = getSystemVersion)]
pub fn get_system_version(this: &Process) -> String;
}
#[wasm_bindgen(module = "electron")]
extern {
#[wasm_bindgen]
pub type BrowserWindow;
/// Cannot call this method if running untrusted content
/// since it requires followin... | code_fim | hard | {
"lang": "rust",
"repo": "x7c1/barley",
"path": "/project-rs/app-renderer/src/js.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Fifthrow/rust-kdb path: /src/symbol.rs
use crate::error::ConversionError;
use crate::kapi;
use std::ffi::{c_void, CStr};
use std::fmt;
use thiserror::Error;
/// Error type for string to symbol conversions
#[derive(Debug, Error)]
pub enum SymbolError {
/// An embedded NUL character was found... | code_fim | hard | {
"lang": "rust",
"repo": "Fifthrow/rust-kdb",
"path": "/src/symbol.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Display for Symbol {
/// Display for symbol will always render a string representation of the symbol. If the
/// string contains invalid characters it will strip them from the string.
/// This function will allocate only if the string conatins invalid utf-8 characters.
fn fmt(&se... | code_fim | hard | {
"lang": "rust",
"repo": "Fifthrow/rust-kdb",
"path": "/src/symbol.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let valid_features: HashSet<FeatureId> = self.features().into_iter().collect();
let mut keep_features = HashSet::new();
let mut missing_features = HashSet::new();
for fid in features {
if valid_features.contains(fid) {
keep_features.insert(fid);
... | code_fim | hard | {
"lang": "rust",
"repo": "jjfiv/fastrank",
"path": "/src/sampling.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn train_test(
&self,
test_fraction: f64,
rand: &mut Rand64,
) -> (SampledDatasetRef, SampledDatasetRef) {
let mut qs = self.queries();
let n_test_qs = ((qs.len() as f64) * test_fraction) as usize;
if n_test_qs == 0 {
panic!(
... | code_fim | hard | {
"lang": "rust",
"repo": "jjfiv/fastrank",
"path": "/src/sampling.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jjfiv/fastrank path: /src/sampling.rs
use crate::dataset::{DatasetRef, RankingDataset, SampledDatasetRef};
use crate::randutil;
use crate::FeatureId;
use crate::InstanceId;
use oorandom::Rand64;
use std::cmp;
use std::collections::HashSet;
pub trait DatasetSampling {
/// Sample this dataset... | code_fim | hard | {
"lang": "rust",
"repo": "jjfiv/fastrank",
"path": "/src/sampling.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
#[derive(Debug, PartialEq)]
pub struct Refed1Table {
ptr : TablePtr,
}
impl Refed1Table {
pub fn new(ptr : TablePtr) -> Refed1Table{ Refed1Table{ ptr } }
pub fn a1(&self) -> Refed1CItem {
let ptr = table::get_value(self.ptr, "a1").unwrap();
Refed1CItem::from(ptr)
}
pub fn a2(&self) -> Refed1C... | code_fim | hard | {
"lang": "rust",
"repo": "dochy-ksti/dochy_intf_gen_app",
"path": "/src/diff/generated_test_list_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self{ ptr }
}
}
impl ListMItem {
pub fn mem(&self) -> i64{
let qv = mitem::get_int(self.ptr, "mem").unwrap();
qv.into_value().unwrap()
}
pub fn set_mem(&mut self, mem : i64){
mitem::set_int(self.ptr, "mem", Qv::Val(mem));
}
pub fn in_list(&mut self) -> MListPtr<InListMItem>{
mitem::get_mil... | code_fim | hard | {
"lang": "rust",
"repo": "dochy-ksti/dochy_intf_gen_app",
"path": "/src/diff/generated_test_list_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dochy-ksti/dochy_intf_gen_app path: /src/diff/generated_test_list_test.rs
use dochy_core::intf::*;
use dochy_core::structs::*;
unsafe impl Send for RootIntf{}
#[derive(Debug, PartialEq)]
pub struct RootIntf{
root : Box<RootObject>,
ptr : RootObjectPtr,
}
impl RootIntf{
pub fn new(obj... | code_fim | hard | {
"lang": "rust",
"repo": "dochy-ksti/dochy_intf_gen_app",
"path": "/src/diff/generated_test_list_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn default_instance() -> &'static Identify {
static mut instance: ::protobuf::lazy::Lazy<Identify> = ::protobuf::lazy::Lazy {
lock: ::protobuf::lazy::ONCE_INIT,
ptr: 0 as *const Identify,
};
unsafe {
instance.get(Identify::new)
}
... | code_fim | hard | {
"lang": "rust",
"repo": "zhaohaijun/rust-libp2p",
"path": "/identify/src/protobuf_structs/structs.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.