text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: darrenhdc/Blind-ECDSA path: /bld_sig/src/protocols/blind_ecdsa/test_sign.rs
use class_group::primitives::cl_dl_lcm::HSMCL;
use curv::cryptographic_primitives::hashing::traits::Hash;
use curv::cryptographic_primitives::hashing::hash_sha256::HSha256;
use curv::elliptic::curves::traits::{ECPoint, E... | code_fim | hard | {
"lang": "rust",
"repo": "darrenhdc/Blind-ECDSA",
"path": "/bld_sig/src/protocols/blind_ecdsa/test_sign.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chorddown/chordr path: /webchordr/persistence/src/web_repository/settings_web_repository_factory.rs
use crate::backend_v2::browser_storage_backend::BrowserStorageBackend;
use crate::backend_v2::persistence_manager::PersistenceManagerV2;
use crate::browser_storage::BrowserStorage;
use crate::comm... | code_fim | hard | {
"lang": "rust",
"repo": "chorddown/chordr",
"path": "/webchordr/persistence/src/web_repository/settings_web_repository_factory.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> type CE = Box<
dyn CommandExecutor<
Context = CommandContext,
Error = WebError,
RecordType = SongSettingsMap,
>,
>;
let browser_storage_backend = Box::new(BrowserStorageBackend::new(browser_storage.clone()));
... | code_fim | hard | {
"lang": "rust",
"repo": "chorddown/chordr",
"path": "/webchordr/persistence/src/web_repository/settings_web_repository_factory.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let persistence_manager: PersistenceManagerV2<SongSettingsMap> =
PersistenceManagerV2::with_backends(command_backends, query_backends);
SettingsWebRepository::new(persistence_manager)
}
}<|fim_prefix|>// repo: chorddown/chordr path: /webchordr/persistence/src/web_repositor... | code_fim | hard | {
"lang": "rust",
"repo": "chorddown/chordr",
"path": "/webchordr/persistence/src/web_repository/settings_web_repository_factory.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(tx, "Temperature Sensor started.\n").unwrap();
let delay = Delay::new(dp.TIMER0);
init::LateResources {
delay,
adc,
analog_pin,
tx,
rx,
}
}
#[task(binds = UART0, resources = [adc, analog_pin, tx, ... | code_fim | hard | {
"lang": "rust",
"repo": "stephanh/microbit-examples",
"path": "/temperature-bluetooth/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stephanh/microbit-examples path: /temperature-bluetooth/src/main.rs
#![no_main]
#![no_std]
use core::fmt::Write;
use panic_halt as _;
use embedded_hal::adc::OneShot;
use microbit::hal::delay::Delay;
use microbit::hal::gpio::{gpio::PIN3, Floating, Input};
use microbit::hal::prelude::*;
use mi... | code_fim | hard | {
"lang": "rust",
"repo": "stephanh/microbit-examples",
"path": "/temperature-bluetooth/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> (_result, _reference)| {
// マイナス無限大が発生しないよう、小さな値を加算(ln(0)=-inf).
acc + _reference * (_result + 1.0e-7).ln()
})
}<|fim_prefix|>// repo: tkyk0317/deeplearning_by_rust path: /src/loss_func.rs
extern crate nalgebra;
use nalgebra::core::{DMatrix};
// ... | code_fim | hard | {
"lang": "rust",
"repo": "tkyk0317/deeplearning_by_rust",
"path": "/src/loss_func.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tkyk0317/deeplearning_by_rust path: /src/loss_func.rs
extern crate nalgebra;
use nalgebra::core::{DMatrix};
// 損失関数.
pub fn sum_of_square(result: &DMatrix<f64>, reference: &DMatrix<f64>) -> f64 {
result.iter()
<|fim_suffix|>fn cross_entropy(result: &DMatrix<f64>, reference: &DMatrix... | code_fim | medium | {
"lang": "rust",
"repo": "tkyk0317/deeplearning_by_rust",
"path": "/src/loss_func.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn cross_entropy(result: &DMatrix<f64>, reference: &DMatrix<f64>) -> f64 {
-1. * result.iter()
.zip(reference.iter())
.fold(0., |acc, (_result, _reference)| {
// マイナス無限大が発生しないよう、小さな値を加算(ln(0)=-inf).
acc + _reference * (_result + 1... | code_fim | medium | {
"lang": "rust",
"repo": "tkyk0317/deeplearning_by_rust",
"path": "/src/loss_func.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) const CHROME: App = App {
name: "Google Chrome",
binary: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
};
impl App {
pub(crate) fn get_or_launch(self) -> Result<WindowHandle, Error> {
let start = Instant::now();
while start.elapsed() < Duration::from_millis(5... | code_fim | medium | {
"lang": "rust",
"repo": "vrkansagara/dotfiles",
"path": "/pkg/space/src/app.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vrkansagara/dotfiles path: /pkg/space/src/app.rs
use crate::common::*;
#[derive(Copy, Clone)]
pub(crate) struct App {
pub(crate) name: &'static str,
pub(crate) binary: &'static str,
}
pub(crate) const ALACRITTY: App = App {
name: "Alacritty",
binary: "/Applications/Alacritty.app/Co... | code_fim | hard | {
"lang": "rust",
"repo": "vrkansagara/dotfiles",
"path": "/pkg/space/src/app.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
if start.elapsed() > Duration::from_millis(500) {
return Err(Error::Launch {
binary: self.binary.to_owned(),
});
}
}
}
}<|fim_prefix|>// repo: vrkansagara/dotfiles path: /pkg/space/src/app.rs
use crate::common::*;
#[derive(Copy, Clone)]
pub(crate) s... | code_fim | hard | {
"lang": "rust",
"repo": "vrkansagara/dotfiles",
"path": "/pkg/space/src/app.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) const CHUNK_MASK: usize = (1 << LOG_BYTES_IN_CHUNK) - 1;
pub(crate) const POLICY_SIDE_METADATA_OFFSET: usize =
BYTES_IN_CHUNK >> GLOBAL_SIDE_METADATA_WORST_CASE_RATIO_LOG;<|fim_prefix|>// repo: PDFxy/mmtk-core path: /src/util/side_metadata/constants.rs
use crate::util::heap::layout::vm_la... | code_fim | hard | {
"lang": "rust",
"repo": "PDFxy/mmtk-core",
"path": "/src/util/side_metadata/constants.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PDFxy/mmtk-core path: /src/util/side_metadata/constants.rs
use crate::util::heap::layout::vm_layout_constants::{BYTES_IN_CHUNK, LOG_BYTES_IN_CHUNK};
use crate::util::Address;
#[cfg(target_pointer_width = "32")]
pub(crate) const SIDE_METADATA_BASE_ADDRESS: Address = unsafe { Address::from_usize(... | code_fim | hard | {
"lang": "rust",
"repo": "PDFxy/mmtk-core",
"path": "/src/util/side_metadata/constants.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) const SIDE_METADATA_PER_CHUNK: usize =
BYTES_IN_CHUNK >> SIDE_METADATA_WORST_CASE_RATIO_LOG;
pub(crate) const CHUNK_MASK: usize = (1 << LOG_BYTES_IN_CHUNK) - 1;
pub(crate) const POLICY_SIDE_METADATA_OFFSET: usize =
BYTES_IN_CHUNK >> GLOBAL_SIDE_METADATA_WORST_CASE_RATIO_LOG;<|fim_pref... | code_fim | hard | {
"lang": "rust",
"repo": "PDFxy/mmtk-core",
"path": "/src/util/side_metadata/constants.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /* Some, if not all of these implementations cannot handle the case where dst \in \{ lhs, rhs \}.
* CalcExpression handles this by copying all supplied idents to local registers first. */
use BinaryCalcOperation::*;
use ParseStatement::*;
// See also exec::test::te... | code_fim | hard | {
"lang": "rust",
"repo": "BenWiederhake/practical-floop",
"path": "/src/parse.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut into = Vec::with_capacity(10);
self.gen_code_recursive(0, dst, &mut into);
into
}
fn gen_code_recursive(self, mut stack_depth: u32, dst: &ParseIdent, into: &mut Vec<ParseStatement>) {
use CalcExpression::*;
match self {
Constant(n) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "BenWiederhake/practical-floop",
"path": "/src/parse.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BenWiederhake/practical-floop path: /src/parse.rs
:CalcTemp(0));
let v0nonzero = ParseIdent::Dynamic(DynamicIdent::CalcTemp(1));
let v1nonzero = ParseIdent::Dynamic(DynamicIdent::CalcTemp(2));
let mut code = vec![
// v0nonzero := (lhs - rhs) > 0
Ad... | code_fim | hard | {
"lang": "rust",
"repo": "BenWiederhake/practical-floop",
"path": "/src/parse.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LordSentox/advent2020 path: /src/11/main.rs
use std::fs;
use std::mem;
use std::str::FromStr;
pub const DIRECTIONS: [(isize, isize); 8] = [
(-1, -1),
(-1, 0),
(-1, 1),
(0, -1),
(0, 1),
(1, -1),
(1, 0),
(1, 1),
];
#[derive(Copy, Clone, PartialEq, Eq)]
enum Tile {... | code_fim | hard | {
"lang": "rust",
"repo": "LordSentox/advent2020",
"path": "/src/11/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // The source and target maps are switched on each step, for now the first map is the source
// map.
{
let mut source_map = &mut map_one;
let mut target_map = &mut map_two;
loop {
perform_step_a(source_map, target_map);
// When we've reached a s... | code_fim | hard | {
"lang": "rust",
"repo": "LordSentox/advent2020",
"path": "/src/11/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pages
.filter(
route_name.eq(route)
.and(page_name.eq(page))
)
.first::<Page>(connection)
.expect(&format!(
"Error loading page {page} for {route} routes",
page=page,
route=route
))
}<|fim_pr... | code_fim | medium | {
"lang": "rust",
"repo": "Servender/template_app",
"path": "/src/database/read/pages.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Servender/template_app path: /src/database/read/pages.rs
use crate::models::database::Page;
use crate::database::DB_POOL;
use diesel::prelude::*;
<|fim_suffix|> let connection = &*DB_POOL.get().unwrap();
pages
.filter(
route_name.eq(route)
.and... | code_fim | medium | {
"lang": "rust",
"repo": "Servender/template_app",
"path": "/src/database/read/pages.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let connection = &*DB_POOL.get().unwrap();
pages
.filter(
route_name.eq(route)
.and(page_name.eq(page))
)
.first::<Page>(connection)
.expect(&format!(
"Error loading page {page} for {route} routes",
page=pag... | code_fim | medium | {
"lang": "rust",
"repo": "Servender/template_app",
"path": "/src/database/read/pages.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hansl/refactory path: /src/virtualfs/src/fs/memory.rs
use crate::error::{Error, IoError, Result};
use crate::fs::FileSystem;
use crate::path::{Component, OwnedPath, Path};
use std::collections::BTreeMap;
use std::fmt::Formatter;
use thiserror::Error as DeriveError;
type MemFsResult<X> = std::re... | code_fim | hard | {
"lang": "rust",
"repo": "hansl/refactory",
"path": "/src/virtualfs/src/fs/memory.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.get_entry(path)?
.as_dir()
.map_err(|err| map_memfs_error(path, err))
}
fn get_file(&self, path: &Path) -> Result<&MemFsEntry> {
self.get_entry(path)?
.as_file()
.map_err(|err| map_memfs_error(path, err))
}
fn get_entry... | code_fim | hard | {
"lang": "rust",
"repo": "hansl/refactory",
"path": "/src/virtualfs/src/fs/memory.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: endeav0r/bad64 path: /tests/testcases.rs
use std::fs;
use std::num::ParseIntError;
#[test]
fn testcases() {
fn fuzzy_eq(expected: &str, actual: &str) -> bool {
fn fuzzy_token(a: &str, b: &str) -> bool {
fn parse_num(n: &str) -> Result<u64, ParseIntError> {
... | code_fim | hard | {
"lang": "rust",
"repo": "endeav0r/bad64",
"path": "/tests/testcases.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let op = u32::from_str_radix(chunks[0], 16).unwrap();
let expected = chunks[1..].join(" ");
let decoded = bad64::decode(op, 0x8000_0000_0000_0004).unwrap();
let actual = format!("{}", decoded);
if !fuzzy_eq(&expected, &actual) {
println!("opcode: {:x... | code_fim | hard | {
"lang": "rust",
"repo": "endeav0r/bad64",
"path": "/tests/testcases.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DrSloth/Crabscript path: /src/c2/iter/map.rs
use crate::{
base::{Args, DayFunction, DayObject, IterHandle},
iter::{Iter, IterKind},
std_modules::conversion::single_value_to_arr,
};
use std::fmt::{Debug, Formatter, Result as FmtRes};
pub fn map(args: Args) -> DayObject {
match (... | code_fim | hard | {
"lang": "rust",
"repo": "DrSloth/Crabscript",
"path": "/src/c2/iter/map.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.inner.rewind()
}
/// Get the exact number of remaining elements or None if not applicable
fn remaining(&self) -> Option<usize> {
self.inner.remaining()
}
/// Get the number of already consumed elements or None if not applicable
fn pos(&self) -> Option<usize> {
... | code_fim | hard | {
"lang": "rust",
"repo": "DrSloth/Crabscript",
"path": "/src/c2/iter/map.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let inner = self.inner.acquire();
Box::new(Self {
inner,
action: self.action.clone(),
args: self.args.clone(),
})
}
/* fn consume(self: Box<Self>) -> Box<dyn Iter> {
let inner = self.inner.consume();
Box::new(Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "DrSloth/Crabscript",
"path": "/src/c2/iter/map.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut reverb: Box<dyn Reverb> = match app_m.subcommand() {
("jcrev", Some(_)) => Box::new(JCRev::new(sample_rate)),
("satrev", Some(_)) => Box::new(SATREV::new(sample_rate)),
("stk-jcrev", Some(sub_m)) => Box::new(STKJCRev::new(
sample_rate,
sub_m.valu... | code_fim | hard | {
"lang": "rust",
"repo": "mosmeh/accent",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mosmeh/accent path: /src/main.rs
use accent::*;
use anyhow::Result;
use clap::{App, AppSettings, Arg, SubCommand};
use hound::{SampleFormat, WavReader, WavSpec, WavWriter};
use itertools::Itertools;
fn main() -> Result<()> {
let arg_input = Arg::with_name("input")
.help("Input WAV f... | code_fim | hard | {
"lang": "rust",
"repo": "mosmeh/accent",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: psat-rs/psat-orb path: /src/lib.rs
pub extern crate orbtk;
extern crate psat;
use std::sync::Arc;
use orbtk::widgets::Widget;
pub struct OrbWindow {
pub window: orbtk::Window
}
impl OrbWindow {
fn add<T: Widget>(&mut self, widget: &Arc<T>) {
<|fim_suffix|> Box::new(orbtk::Butto... | code_fim | hard | {
"lang": "rust",
"repo": "psat-rs/psat-orb",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> window.add(&self);
}
fn as_button(&self) -> Option<&orbtk::Button> {
Some(self)
}
}
impl psat::Target for OrbWindow {
type Component = Box<OrbComponent>;
type Context = ();
fn get_context(&mut self) -> &Self::Context {
&()
}
fn set_root(&mut self, w... | code_fim | medium | {
"lang": "rust",
"repo": "psat-rs/psat-orb",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Downloaded {}%", progress.get());
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut r#loop = Loop::default()?;
let progress = Rc::new(Cell::new(0f32));
let progress2 = progress.clone();
let mut notify = r#loop.r#async(move |_| print_progress(&progress))?;
... | code_fim | hard | {
"lang": "rust",
"repo": "Icemic/libuv-rs",
"path": "/examples/progress.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Icemic/libuv-rs path: /examples/progress.rs
//! Run:
//!
//! ```bash
//! cargo run --example progress
//! ```
extern crate libuv;
use libuv::prelude::*;
use libuv::AsyncHandle;
use std::cell::Cell;
use std::rc::Rc;
const SIZE: usize = 10240;
<|fim_suffix|> println!("Download complete");
... | code_fim | hard | {
"lang": "rust",
"repo": "Icemic/libuv-rs",
"path": "/examples/progress.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut downloaded = 0usize;
while downloaded < SIZE {
progress.replace((downloaded as f32) * 100.0 / (SIZE as f32));
if let Err(e) = notify.send() {
eprintln!("Failed to send async notification {}", e);
}
std::thread::sleep(std::time::Duration::from_sec... | code_fim | medium | {
"lang": "rust",
"repo": "Icemic/libuv-rs",
"path": "/examples/progress.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
unsafe fn slice_unchecked(&self, range: Range<usize>) -> &[u8] {
debug_assert!(
range.start <= self.len() && range.end <= self.len(),
"Reading out of bounds {:?} for {}!",
range,
self.len()
);
self.get_unchecked(ran... | code_fim | hard | {
"lang": "rust",
"repo": "maciejhirsz/logos",
"path": "/logos/src/source.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.len()
}
#[inline]
fn read<'a, Chunk>(&'a self, offset: usize) -> Option<Chunk>
where
Chunk: self::Chunk<'a>,
{
if offset + (Chunk::SIZE - 1) < self.len() {
Some(unsafe { Chunk::from_ptr(self.as_ptr().add(offset)) })
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "maciejhirsz/logos",
"path": "/logos/src/source.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maciejhirsz/logos path: /logos/src/source.rs
//! This module contains a bunch of traits necessary for processing byte strings.
//!
//! Most notable are:
//! * `Source` - implemented by default for `&str` and `&[u8]`, used by the `Lexer`.
//! * `Slice` - slices of `Source`, returned by `Lexer::sl... | code_fim | hard | {
"lang": "rust",
"repo": "maciejhirsz/logos",
"path": "/logos/src/source.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Client::new(&aws_config::load_from_env().await)
.put_object()
.bucket(&bucket_name)
.key(&key)
.body(ByteStream::from(image))
.content_type("image/gif")
.metadata("title", &comic.title)
.send()
.await
.with_context(|| format!("fai... | code_fim | hard | {
"lang": "rust",
"repo": "MFrank2016/dilbert-feed",
"path": "/src/bin/get-strip/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let comic = ClientBuilder::default()
.http_client(http_client.clone())
.build()?
.scrape_comic(input.date)
.await?;
info!("Scraping done: {:?}", comic);
info!("Downloading strip from {} ...", comic.strip_url);
let image = http_client
.get(&comic.im... | code_fim | hard | {
"lang": "rust",
"repo": "MFrank2016/dilbert-feed",
"path": "/src/bin/get-strip/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MFrank2016/dilbert-feed path: /src/bin/get-strip/main.rs
#![deny(clippy::all, clippy::nursery)]
#![deny(nonstandard_style, rust_2018_idioms)]
use anyhow::{Context, Result};
use aws_sdk_s3::{ByteStream, Client};
use chrono::NaiveDate;
use lambda_runtime::{handler_fn, Context as LambdaContext, Er... | code_fim | hard | {
"lang": "rust",
"repo": "MFrank2016/dilbert-feed",
"path": "/src/bin/get-strip/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RJPlog/aoc-2020 path: /day23/rust/mr-kaffee/src/lib.rs
use std::cmp::min;
// tag::play_round[]
pub fn play_round(list: &mut Vec<Item>, curr: usize) -> usize {
// get current item
let curr_next = list[curr].next;
// get next three items
let n1 = curr_next;
let n2 = list[n1].... | code_fim | hard | {
"lang": "rust",
"repo": "RJPlog/aoc-2020",
"path": "/day23/rust/mr-kaffee/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // set next links
for k in 0..len {
list[k].next = (k + 1) % len;
}
// set low links for tail part, which is sorted
for k in data.len() + 1..len {
list[k].low = k - 1;
}
// set low links for head part, which is unsorted
... | code_fim | hard | {
"lang": "rust",
"repo": "RJPlog/aoc-2020",
"path": "/day23/rust/mr-kaffee/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn index_buffer(&self) -> &Buffer<u32> {
&self.mesh_index_buffer
}
pub fn vertex_buffer(&self) -> &Buffer<MeshVertex> {
&self.mesh_vertex_buffer
}
pub fn materials(&self) -> &Vec<Material> {
&self.materials
}
pub fn textures(&self) -> &Vec<Texture> {
&self.textures
}... | code_fim | hard | {
"lang": "rust",
"repo": "lilith645/Maat-Graphics",
"path": "/src/extra/gltf_loader.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> node_idx
};
let sampler = channel.sampler();
let interpolation = {
match sampler.interpolation() {
gltf::animation::Interpolation::Linear => AnimationInterpolation::Linear,
gltf::animation::Interpolation::Step => AnimationInterpolation::Step,
... | code_fim | hard | {
"lang": "rust",
"repo": "lilith645/Maat-Graphics",
"path": "/src/extra/gltf_loader.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lilith645/Maat-Graphics path: /src/extra/gltf_loader.rs
gltf: &gltf::Document,
buffers: &[gltf::buffer::Data],
images: &mut Vec<vkimage>,
) {
let gltf_images = gltf.images();
for image in gltf_images {
let image_data = image.source();
let some_image = {
match image_data ... | code_fim | hard | {
"lang": "rust",
"repo": "lilith645/Maat-Graphics",
"path": "/src/extra/gltf_loader.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fspiekermann/rusty_pizza path: /rusty_pizza_server/src/util/id_provider.rs
use crate::util::id::Id;
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct IdProvider {
next_id: u32,
}
<|fim_suffix|> #[test]
fn second_id_is_one() {
// Given:
let mut id_provider = IdProvider... | code_fim | hard | {
"lang": "rust",
"repo": "fspiekermann/rusty_pizza",
"path": "/rusty_pizza_server/src/util/id_provider.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // When:
let id = id_provider.generate_next();
// Then:
assert_eq!(id, Id::new(0));
}
#[test]
fn second_id_is_one() {
// Given:
let mut id_provider = IdProvider::new();
id_provider.generate_next();
// When:
let id = id_... | code_fim | hard | {
"lang": "rust",
"repo": "fspiekermann/rusty_pizza",
"path": "/rusty_pizza_server/src/util/id_provider.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>yond the 53 most significant
// We want to know only 2 things. If the msb of the dropped bits is 1 or 0,
// and if any of the other bits are 1. (See blog for explanation)
// So we take care to preserve the msb bit, while jumbling the rest of the bits
// together so that any 1s will survive. If all... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/parity-common",
"path": "/primitive-types/src/fp_conversion.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paritytech/parity-common path: /primitive-types/src/fp_conversion.rs
use super::U256;
impl U256 {
/// Lossy saturating conversion from a `f64` to a `U256`. Like for floating point to
/// primitive integer type conversions, this truncates fractional parts.
///
/// The conversion follows the ... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/parity-common",
"path": "/primitive-types/src/fp_conversion.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nixpulvis/hell path: /13/evolution/evolution-wire/tests/src/feed_choice.rs
use serde_json as json;
use evolution_wire::*;
// TODO: Deserialize.
#[test]
fn serde_false() {
assert_serde! {
FeedChoice,
"false"
};
}
#[test]
fn serde_vegetarian() {
assert_serde! {
... | code_fim | hard | {
"lang": "rust",
"repo": "nixpulvis/hell",
"path": "/13/evolution/evolution-wire/tests/src/feed_choice.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let choice = FeedChoice::Abstain;
let json = json::to_string(&choice).unwrap();
let expected = "false";
assert_eq!(expected, json);
}
#[test]
fn serde_feed() {
let choice = FeedChoice::Feed(Natural(0));
let json = json::to_string(&choice).unwrap();
let expected = "0";
asse... | code_fim | medium | {
"lang": "rust",
"repo": "nixpulvis/hell",
"path": "/13/evolution/evolution-wire/tests/src/feed_choice.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn serde_attack() {
let choice = FeedChoice::Attack(Natural(5), Natural(3), Natural(2));
let json = json::to_string(&choice).unwrap();
let expected = "[5,3,2]";
assert_eq!(expected, json);
}<|fim_prefix|>// repo: nixpulvis/hell path: /13/evolution/evolution-wire/tests/src/feed_cho... | code_fim | hard | {
"lang": "rust",
"repo": "nixpulvis/hell",
"path": "/13/evolution/evolution-wire/tests/src/feed_choice.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Set the link that the notification will follow when tapped (same as calling `extra`).
///
/// # Examples
/// ```rust
/// let notification = Builder::new("Rusty content".to_owned())
/// .url("https://www.rust-lang.org".to_owned())
/// .build();
/// ```
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "scotow/nustify",
"path": "/src/notification.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scotow/nustify path: /src/notification.rs
#[cfg(feature="imgur")]
use {
crate::error::Error,
std::borrow::Cow
};
/// A out-going notification. May be sent multiple times with the `nustify::send` function.
#[derive(Debug, Clone)]
pub struct Notification {
pub(crate) title: Option<Str... | code_fim | hard | {
"lang": "rust",
"repo": "scotow/nustify",
"path": "/src/notification.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Diagnostic)]
#[diagnostic(
category = "format",
severity = Information,
message = "Formatter would have printed the following content:"
)]
pub(crate) struct FormatDiffDiagnostic {
#[location(resource)]
pub(crate) file_name: String,
#[advice]
pub(crate) diff: ContentDiffAdvi... | code_fim | hard | {
"lang": "rust",
"repo": "rome/tools",
"path": "/crates/rome_cli/src/execute/diagnostics.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T, E> ResultExt for Result<T, E>
where
E: std::error::Error + Send + Sync + 'static,
{
type Result = T;
fn with_file_path_and_code(
self,
file_path: String,
code: &'static Category,
) -> Result<Self::Result, Error> {
self.map_err(move |err| {
... | code_fim | hard | {
"lang": "rust",
"repo": "rome/tools",
"path": "/crates/rome_cli/src/execute/diagnostics.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rome/tools path: /crates/rome_cli/src/execute/diagnostics.rs
use rome_diagnostics::adapters::{IoError, StdError};
use rome_diagnostics::{Advices, Category, Diagnostic, DiagnosticExt, Error, Severity, Visit};
use rome_text_edit::TextEdit;
use std::io;
#[derive(Debug, Diagnostic)]
#[diagnostic(
... | code_fim | hard | {
"lang": "rust",
"repo": "rome/tools",
"path": "/crates/rome_cli/src/execute/diagnostics.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vsrs/rdisk path: /tests/vhd.rs
use rdisk::mbr;
use rdisk::prelude::*;
use rdisk::vhd::{VhdImage, VhdKind};
use rdisk_shared::AsByteSliceMut;
mod shared;
use shared::*;
fn check_no_read_footer(disk: &VhdImage) {
let size = disk.capacity().unwrap();
assert_eq!(3145728, size);
let mu... | code_fim | hard | {
"lang": "rust",
"repo": "vsrs/rdisk",
"path": "/tests/vhd.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some((disk, _full_path)) = open_test_vhd("vhd_dynamic_small_gpt.vhd") {
let disk = PartitionedDisk::new(disk).unwrap();
assert_eq!(1, disk.layout().partitions().count());
assert_eq!(1, disk.partitions().count());
let partition = disk.partitions().nth(0).unw... | code_fim | hard | {
"lang": "rust",
"repo": "vsrs/rdisk",
"path": "/tests/vhd.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn read_child_proof(
&self,
hash: Block::Hash,
child_info: &ChildInfo,
keys: &mut dyn Iterator<Item = &[u8]>,
) -> sp_blockchain::Result<StorageProof> {
self.state_at(hash)
.and_then(|state| prove_child_read(state, child_info, keys).map_err(Into::into))
}
fn execution_proof(
&self,
h... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/client/service/src/client/client.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paritytech/substrate path: /client/service/src/client/client.rs
t summary) => {
let import_notification_action = summary.import_notification_action;
let storage_changes = summary.storage_changes.take();
(
Some(BlockImportNotification::from_summary(
summary,
... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/client/service/src/client/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paritytech/substrate path: /client/service/src/client/client.rs
{
&self.finality_notification_sinks
}
/// Get a reference to the state at a given block.
pub fn state_at(&self, hash: Block::Hash) -> sp_blockchain::Result<B::State> {
self.backend.state_at(hash)
}
/// Get the code at a ... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/substrate",
"path": "/client/service/src/client/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
}
fn init(&mut self) -> Result<()> {
self.sample_counter = 0;
self.data = Collector::new()?;
self.running = false;
Ok(())
}
pub fn stop(&mut self) -> Result<()> {
log::info!("stopping cpu profiler");
if self.ru... | code_fim | hard | {
"lang": "rust",
"repo": "lovetrading10/pprof-rs",
"path": "/src/profiler.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lovetrading10/pprof-rs path: /src/profiler.rs
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use std::convert::TryInto;
use std::os::raw::c_int;
use backtrace::Frame;
use nix::sys::signal;
use parking_lot::RwLock;
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))... | code_fim | hard | {
"lang": "rust",
"repo": "lovetrading10/pprof-rs",
"path": "/src/profiler.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn malloc(size: usize) -> *mut c_void;
}
thread_local! {
static FLAG: RefCell<bool> = RefCell::new(false);
}
extern "C" fn malloc_hook(size: usize) -> *mut c_void {
unsafe {
__malloc_hook = None;
}
FLAG.with(|flag| {
flag.r... | code_fim | hard | {
"lang": "rust",
"repo": "lovetrading10/pprof-rs",
"path": "/src/profiler.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match *self {
Request::Destroy => true,
_ => false,
}
}
fn opcode(&self) -> u16 {
match *self {
Request::SetGamma { .. } => 0,
Request::Destroy => 1,
}
}
fn child... | code_fim | hard | {
"lang": "rust",
"repo": "MPTGits/QuestGiverRustGame",
"path": "/target/debug/build/wayland-protocols-ac1a20a560d181a7/out/wlr-gamma-control-v1_c_client_api.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut formatter = f.debug_struct("MssPackage");
formatter.field("encryption", &self.encryption);
formatter.field("mss_manifests", &self.mss_manifests);
formatter.field("segment_duration_seconds", &self.segment_duration_seconds);
formatter.finish()
}
}
/// See ... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/mediapackagevod/src/model.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/mediapackagevod/src/model.rs
s setting controls how ad markers are included in the packaged OriginEndpoint.
/// "NONE" will omit all SCTE-35 ad markers from the output.
/// "PASSTHROUGH" causes the manifest to contain a copy of the SCTE-35 ad
... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/mediapackagevod/src/model.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/mediapackagevod/src/model.rs
formatter.field("speke_key_provider", &self.speke_key_provider);
formatter.finish()
}
}
/// See [`DashEncryption`](crate::model::DashEncryption)
pub mod dash_encryption {
/// A builder for [`DashEncryption`](crate::mod... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/mediapackagevod/src/model.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(self.exponent, other.exponent); // Nope
Number {
integer: self.integer - other.integer,
decimal: self.decimal - other.decimal,
exponent: self.exponent,
base: self.base,
}
}
}
impl fmt::Display for Number {
fn fmt(&... | code_fim | hard | {
"lang": "rust",
"repo": "hrvolapeter/javascript-es9-parser",
"path": "/components/evaluator-lib/src/value.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Add for Number {
type Output = Self;
fn add(self, other: Self) -> Self {
assert_eq!(self.exponent, other.exponent); // Nope
Number {
integer: self.integer + other.integer,
decimal: self.decimal + other.decimal,
exponent: self.exponent,
... | code_fim | hard | {
"lang": "rust",
"repo": "hrvolapeter/javascript-es9-parser",
"path": "/components/evaluator-lib/src/value.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hrvolapeter/javascript-es9-parser path: /components/evaluator-lib/src/value.rs
use crate::{function::Function, object::ObjectData};
use gc::{Gc, GcCell};
use js_parser::{javascript_lexer::token, node};
use std::{
cmp::Ordering,
fmt,
ops::{Add, Sub},
};
// 6.2.3 https://tc39.github.i... | code_fim | hard | {
"lang": "rust",
"repo": "hrvolapeter/javascript-es9-parser",
"path": "/components/evaluator-lib/src/value.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: euclio/hubcaps path: /examples/hooks.rs
extern crate env_logger;
extern crate hyper;
extern crate hubcaps;
extern crate hyper_native_tls;
use hyper::Client;
use hyper::net::HttpsConnector;
use hyper_native_tls::NativeTlsClient;
use hubcaps::{Credentials, Github};
use hubcaps::hooks::{HookCreate... | code_fim | hard | {
"lang": "rust",
"repo": "euclio/hubcaps",
"path": "/examples/hooks.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // close stream on second request to simulate crash
let _ = stream.try_next().await?;
std::mem::drop(stream);
Ok(())
}
});
let auth_provider_fut = auth_provider_supplier.run();
let test_fut = async move {... | code_fim | hard | {
"lang": "rust",
"repo": "opensource-assist/fuschia",
"path": "/src/identity/lib/token_manager/src/auth_provider_cache.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let auth_provider_fut = auth_provider_supplier.run();
let test_fut = async move {
let cache = AuthProviderCache::new(auth_provider_supplier);
// first get call should create a fresh proxy
cache
.get_oauth_open_id_connect_proxy("crashes"... | code_fim | hard | {
"lang": "rust",
"repo": "opensource-assist/fuschia",
"path": "/src/identity/lib/token_manager/src/auth_provider_cache.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: opensource-assist/fuschia path: /src/identity/lib/token_manager/src/auth_provider_cache.rs
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use crate::error::{ResultExt, TokenManag... | code_fim | hard | {
"lang": "rust",
"repo": "opensource-assist/fuschia",
"path": "/src/identity/lib/token_manager/src/auth_provider_cache.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn derivative_is_stable_with_large_values() {
let dl = dlogit(15466372000.0);
assert_approx_eq!(dl, 0.0);
}
#[test]
fn derivative_is_stable_with_negative_large_values() {
let dl = dlogit(-15466372000.0);
assert_approx_eq!(dl, 0.0);
}<|fim_prefix|>// repo: jonathanlb/lair path: /s... | code_fim | hard | {
"lang": "rust",
"repo": "jonathanlb/lair",
"path": "/src/logit_test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn logit_is_stable_with_negative_large_values() {
let x = logit(-15466372000.0);
assert_approx_eq!(x, 0.0);
}
#[test]
fn derivative_is_stable_with_large_values() {
let dl = dlogit(15466372000.0);
assert_approx_eq!(dl, 0.0);
}
#[test]
fn derivative_is_stable_with_negative_large_va... | code_fim | hard | {
"lang": "rust",
"repo": "jonathanlb/lair",
"path": "/src/logit_test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonathanlb/lair path: /src/logit_test.rs
use super::*;
use assert_approx_eq::assert_approx_eq;
use na::{Matrix1, Matrix1x3, Matrix2x1, Matrix2x3};
use na::{U1, U2};
use crate::{LinearModel, Model, SGDTrainer, UpdateParams};
const LEARNING_PARAMS: UpdateParams = UpdateParams {
step_size: ... | code_fim | hard | {
"lang": "rust",
"repo": "jonathanlb/lair",
"path": "/src/logit_test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let quit = "q".as_bytes();
loop {
let input = term.read();
if input != &[] {
unsafe { println!("{}, {:?}", str::from_utf8_unchecked(input), input) };
if input == quit {
break
}
}
}
}<|fim_prefix|>// repo: samuelsleig... | code_fim | easy | {
"lang": "rust",
"repo": "samuelsleight/gosh",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: samuelsleight/gosh path: /src/main.rs
#[macro_use]
extern crate lazy_static;
extern crate termios;
use std::str;
mod term;
fn main() {
let mut term = term::TermWrap::stdin();
let quit = "q".as_bytes();
loop {
let input = term.read();
<|fim_suffix|> if input =... | code_fim | medium | {
"lang": "rust",
"repo": "samuelsleight/gosh",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut term = term::TermWrap::stdin();
let quit = "q".as_bytes();
loop {
let input = term.read();
if input != &[] {
unsafe { println!("{}, {:?}", str::from_utf8_unchecked(input), input) };
if input == quit {
break
}
... | code_fim | easy | {
"lang": "rust",
"repo": "samuelsleight/gosh",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>is field."]
pub _non_exhaustive_do_not_use: crate::seal::Seal,
}
impl WebHandle {
pub fn empty() -> WebHandle {
#[allow(deprecated)]
WebHandle {
id: 0,
_non_exhaustive_do_not_use: crate::seal::Seal,
}
}
}<|fim_prefix|>// repo: EmbarkStudios/raw-... | code_fim | hard | {
"lang": "rust",
"repo": "EmbarkStudios/raw-window-handle",
"path": "/src/web.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>assigned their own unique ID.
/// 0 should be reserved for invalid / null IDs.
pub id: u32,
#[doc(hidden)]
#[deprecated = "This field is used to ensure that this struct is non-exhaustive, so that it may be extended in the future. Do not refer to this field."]
pub _non_exhaustive_do_not... | code_fim | hard | {
"lang": "rust",
"repo": "EmbarkStudios/raw-window-handle",
"path": "/src/web.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EmbarkStudios/raw-window-handle path: /src/web.rs
/// Raw window handle for the web
///
/// ## Construction
/// ```
/// # use raw_window_handle::web::WebHandle;
/// let handle = WebHandle {
/// /* fields */
/// ..WebHandle::empty()
/// };
/// ```
#[derive(Debug, Clone, Copy, PartialEq, E... | code_fim | hard | {
"lang": "rust",
"repo": "EmbarkStudios/raw-window-handle",
"path": "/src/web.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rheehot/FFXIVTools path: /libs/ffxiv_parser/src/ex/definition.rs
use core::mem::size_of;
use util::SliceByteOrderExt;
#[derive(Clone)]
#[repr(C)]
pub struct U16BE {
raw: [u8; 2],
}
impl U16BE {
pub fn get(&self) -> u16 {
u16::from_be_bytes(self.raw)
}
}
#[derive(Clone)]
#... | code_fim | hard | {
"lang": "rust",
"repo": "rheehot/FFXIVTools",
"path": "/libs/ffxiv_parser/src/ex/definition.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[repr(C)]
pub struct ExdMultiRowDataItemHeader {
pub sub_index: U16BE,
}
#[repr(C)]
pub struct ExdMultiRowDataHeader {
pub length: U32BE,
pub count: U16BE,
}
#[repr(C)]
pub struct ExdDataHeader {
pub length: U32BE,
_unk: u16,
}
#[derive(Eq, PartialEq, Copy, Clone)]
pub enum ExField... | code_fim | hard | {
"lang": "rust",
"repo": "rheehot/FFXIVTools",
"path": "/libs/ffxiv_parser/src/ex/definition.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shakyShane/topics-2 path: /ir/src/config.rs
use crate::{InputLanguage, IrItem};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use typescript_definitions::TypeScriptify;
<|fim_suffix|>#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Eq, Hash, TypeScriptify)]
pu... | code_fim | medium | {
"lang": "rust",
"repo": "shakyShane/topics-2",
"path": "/ir/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, Eq, Hash, TypeScriptify)]
pub struct ConfigParams {
language: Option<InputLanguage>,
}<|fim_prefix|>// repo: shakyShane/topics-2 path: /ir/src/config.rs
use crate::{InputLanguage, IrItem};
use serde::{Deserialize, Deserializer, Serial... | code_fim | hard | {
"lang": "rust",
"repo": "shakyShane/topics-2",
"path": "/ir/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mStegall/advent2018 path: /src/bin/day02/problem2.rs
use std::collections::HashSet;
fn main() {
let data = include_str!("input.txt");
let mut box_ids: HashSet<String> = HashSet::new();
let mut found_box_1 = String::new();
let mut found_box_2 = String::new();
'main: for box_i... | code_fim | hard | {
"lang": "rust",
"repo": "mStegall/advent2018",
"path": "/src/bin/day02/problem2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let common: String = found_box_1
.chars()
.zip(found_box_2.chars())
.filter_map(|(a, b)| if a == b {Some(a)} else {None})
.collect();
println!("{}", common);
}<|fim_prefix|>// repo: mStegall/advent2018 path: /src/bin/day02/problem2.rs
use std::collections::HashSet;... | code_fim | hard | {
"lang": "rust",
"repo": "mStegall/advent2018",
"path": "/src/bin/day02/problem2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> box_ids.insert(box_id.to_string());
}
let common: String = found_box_1
.chars()
.zip(found_box_2.chars())
.filter_map(|(a, b)| if a == b {Some(a)} else {None})
.collect();
println!("{}", common);
}<|fim_prefix|>// repo: mStegall/advent2018 path: /src/b... | code_fim | hard | {
"lang": "rust",
"repo": "mStegall/advent2018",
"path": "/src/bin/day02/problem2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oulamineYou/pt2itp path: /native/src/stats/mod.rs
use neon::prelude::*;
use super::stream::GeoStream;
#[derive(Serialize, Deserialize, Debug)]
struct StatsArgs {
input: Option<String>
}
impl StatsArgs {
pub fn new() -> Self {
StatsArgs {
input: None
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "oulamineYou/pt2itp",
"path": "/native/src/stats/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> addr
}
}
}
}
}
fn count_intersections(feat: &geojson::Feature) -> i64 {
match feat.properties {
None => 0,
Some(ref props) => match props.get(&String::from("carmen:intersections")) {
None => 0,
Some(pr... | code_fim | hard | {
"lang": "rust",
"repo": "oulamineYou/pt2itp",
"path": "/native/src/stats/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cstyles/advent-of-code-2019 path: /day-06/src/main.rs
use std::collections::{HashMap, HashSet, VecDeque};
use std::fs;
use std::env::args;
fn main() {
let input = fs::read_to_string("input.txt").unwrap();
let orbits: Vec<&str> = input.lines().collect();
let mut bodies: HashSet<&str... | code_fim | hard | {
"lang": "rust",
"repo": "cstyles/advent-of-code-2019",
"path": "/day-06/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> orbiters: &HashMap<&'a str, Vec<&'a str>>,
start: &'a str,
end: &'a str
) -> Result<Vec<&'a str>, ()> {
if start == end {
let end_vec = vec![end];
Ok(end_vec)
} else {
if let Some(body_orbiters) = orbiters.get(start) {
for body_orbiter in body_orbite... | code_fim | hard | {
"lang": "rust",
"repo": "cstyles/advent-of-code-2019",
"path": "/day-06/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn version_major_int() -> Result<i32> {
let version_str = ICUConfig::version_major()?;
Ok(version_str.parse().unwrap())
}
}
}
#[cfg(feature = "icu_config")]
fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_BACKTRACE", "full");
let icu_major... | code_fim | hard | {
"lang": "rust",
"repo": "google/rust_icu",
"path": "/rust_icu_uloc/build.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.