text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let mut start = arrow.loc; let start_idx = backward_nodes[&start].clone(); start += vel; while self.input.in_bounds(&start) { let check_arrow = grid[start.0 as usize][start.1 as usize]; // Only create...
code_fim
hard
{ "lang": "rust", "repo": "fisherdarling/maze_project", "path": "/src/graph.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: snuk182/scintilla-sys-rs path: /build_qt.rs extern crate cc; use std::env; use std::process::Command; pub fn main() { Command::new("git").args(&["checkout", "rel-4-0-2"]).status().unwrap(); let mut qt_location = String::from_utf8(Command::new("qmake").args(&["-query", "QT_INSTALL_HEAD...
code_fim
hard
{ "lang": "rust", "repo": "snuk182/scintilla-sys-rs", "path": "/build_qt.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> cc_build .include("ScintillaEditBase") .include("../../qt") .flag("-isystem") .flag(&format!("{}", qt_location)) .flag("-isystem") .flag(&format!("{}/QtCore", qt_location)) .flag("-isystem") .flag(&format!("{}/QtGui", qt_location)) ...
code_fim
hard
{ "lang": "rust", "repo": "snuk182/scintilla-sys-rs", "path": "/build_qt.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // fn save(&mut self, path: &str) -> Result<()> { // let mut file = File::create(path)?; // let js = if self.print_pretty { serde_json::to_string_pretty(self)? } else { serde_json::to_string(self)? }; // file.write_all(js.as_bytes())?; // self.stats.clear(); // ...
code_fim
hard
{ "lang": "rust", "repo": "gwierzchowski/cryptoexch", "path": "/src/zonda/trading_stats/json.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gwierzchowski/cryptoexch path: /src/zonda/trading_stats/json.rs /*! * Implementation of JSON output format of trading/stats" API from "Zonda" module. */ use std::any::Any; use std::convert::{TryFrom, TryInto}; use anyhow::{Result, Error}; use async_trait::async_trait; <|fim_suffix|> ...
code_fim
hard
{ "lang": "rust", "repo": "gwierzchowski/cryptoexch", "path": "/src/zonda/trading_stats/json.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> cmd!(sh, "git fetch {remote}").run()?; match flags.commit { None => cmd!(sh, "git rebase {remote}/{branch}"), Some(commit) => cmd!(sh, "git rebase --onto {remote}/{branch} {commit}^"), } .run()?; Ok(()) }<|fim_prefix|>// repo: matklad/config path: /xtool/src/git_refres...
code_fim
hard
{ "lang": "rust", "repo": "matklad/config", "path": "/xtool/src/git_refresh.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matklad/config path: /xtool/src/git_refresh.rs use xshell::{cmd, Shell}; pub(crate) fn run(sh: &Shell) -> anyhow::Result<()> { let flags = xflags::parse_or_exit! { optional commit: String }; <|fim_suffix|> cmd!(sh, "git fetch {remote}").run()?; match flags.commit { None => c...
code_fim
hard
{ "lang": "rust", "repo": "matklad/config", "path": "/xtool/src/git_refresh.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gsou/ricsctl path: /src/gui.rs #![cfg(feature="gui")] use gtk::prelude::*; use gio::prelude::*; use super::rlua::Lua; use super::rlua; use super::gtk; use super::gio; use super::glib; use super::server; use super::rics; use std::rc::{Rc}; use std::path::PathBuf; use std::cell::{RefCell, RefMut...
code_fim
hard
{ "lang": "rust", "repo": "gsou/ricsctl", "path": "/src/gui.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> } } }); let can_store_clone = Rc::clone(&can_store); let lua_clone = Rc::clone(&lua); let status_clone = Rc::clone(&status); builder.get_object::<gtk::MenuItem>("filter_apply").unwrap().connect_activate(move |_| { apply_filter(&*lua_clone, &mut can_store_c...
code_fim
hard
{ "lang": "rust", "repo": "gsou/ricsctl", "path": "/src/gui.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fonline-roleplay/rust_workspace path: /dll/fo_engine_types_bindings/generate/src/main.rs #[cfg(feature = "generate")] mod generate { #[cfg(feature = "r357")] const PATH_OUT: &str = "../src/generated/r357/"; #[cfg(feature = "r476")] const PATH_OUT: &str = "../src/generated/r476/";...
code_fim
hard
{ "lang": "rust", "repo": "fonline-roleplay/rust_workspace", "path": "/dll/fo_engine_types_bindings/generate/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let opaque_types = ["Spinlock", "SyncObj", "Mutex"]; generate_custom( true, &opaque_types, &opaque_types, &["ScriptArray_ArrayBuffer"], "", "opaque.rs", ); let number_types = [ "uint8", "ui...
code_fim
hard
{ "lang": "rust", "repo": "fonline-roleplay/rust_workspace", "path": "/dll/fo_engine_types_bindings/generate/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let prefix = if server { "server/" } else { "client/" }; std::fs::create_dir_all(format!("{}{}", PATH_OUT, prefix)).unwrap(); generate_custom( server, &[ "Critter", "Client", "Npc", "NpcPlane",...
code_fim
hard
{ "lang": "rust", "repo": "fonline-roleplay/rust_workspace", "path": "/dll/fo_engine_types_bindings/generate/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let input = include_str!("input_08.txt"); let mut data = input.trim().split(" ").map(|s| s.parse().unwrap()); let root: Node = Node::parse(&mut data); println!("{}", root.sum()) }<|fim_prefix|>// repo: fbenkstein/advent-of-code path: /fbenkstein/rust/src/bin/aoc08_02.rs #[der...
code_fim
hard
{ "lang": "rust", "repo": "fbenkstein/advent-of-code", "path": "/fbenkstein/rust/src/bin/aoc08_02.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fbenkstein/advent-of-code path: /fbenkstein/rust/src/bin/aoc08_02.rs #[derive(Debug, Clone)] struct Node { children: Vec<Node>, metadata: Vec<u32>, } impl Node { fn parse<T: Iterator<Item = u32>>(data: &mut T) -> Node { let child_count = data.next().expect("child count"); ...
code_fim
medium
{ "lang": "rust", "repo": "fbenkstein/advent-of-code", "path": "/fbenkstein/rust/src/bin/aoc08_02.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_parse_desc_proficiency_targets() { let text = "simple and martial weapons and unarmed attacks"; let expected = &["simple weapons", "martial weapons", "unarmed attacks"]; let actual = proficiency_targets(text).unwrap(); assert_eq!(expected, actual.as_...
code_fim
hard
{ "lang": "rust", "repo": "cassiemeharry/pf2e-csheet", "path": "/aon2e-scraper/src/parsers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> rule you() = "You" / "you" rule word() -> &'input str = titlecase_word() / lowercase_word() rule titlecase_word() -> &'input str = $(['A'..='Z'] ['a'..='z']*) rule lowercase_word() -> &'input str = $(['a'..='z']+) } } pub use self::parsers::*; ...
code_fim
hard
{ "lang": "rust", "repo": "cassiemeharry/pf2e-csheet", "path": "/aon2e-scraper/src/parsers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cassiemeharry/pf2e-csheet path: /aon2e-scraper/src/parsers.rs use pf2e_csheet_shared::{ calc::CalculatedString, choices::{Choice, ChoiceMeta}, cond::{Condition, ProficiencyCondition, SingleCondition, UnenforcedCondition}, effects::{self, Effect}, items::ArmorCategory, sta...
code_fim
hard
{ "lang": "rust", "repo": "cassiemeharry/pf2e-csheet", "path": "/aon2e-scraper/src/parsers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mbiggio/gobject-example-rs path: /src/foo/ffi.rs use glib_ffi; use gobject_ffi; use libc::c_char; #[repr(C)] pub struct Foo { pub parent: gobject_ffi::GObject, } #[repr(C)] pub struct FooClass { pub parent_class: gobject_ffi::GObjectClass, pub increment: Option<unsafe extern "C" fn...
code_fim
medium
{ "lang": "rust", "repo": "mbiggio/gobject-example-rs", "path": "/src/foo/ffi.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn ex_foo_increment(this: *mut Foo, inc: i32) -> i32; pub fn ex_foo_get_counter(this: *mut Foo) -> i32; pub fn ex_foo_get_name(this: *mut Foo) -> *mut c_char; }<|fim_prefix|>// repo: mbiggio/gobject-example-rs path: /src/foo/ffi.rs use glib_ffi; use gobject_ffi; use libc::c_char; #[repr(...
code_fim
medium
{ "lang": "rust", "repo": "mbiggio/gobject-example-rs", "path": "/src/foo/ffi.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bagar0x60/sandsim path: /src/model/sand_graph.rs pub type NodeIndex = usize; pub type EdgeIndex = usize; use std::cell::Cell; #[derive(Debug)] pub struct NodeData { pub sand: Cell<i32>, pub degree: i32, first_outgoing_edge: Option<EdgeIndex> } #[derive(Debug)] pub struct EdgeDat...
code_fim
hard
{ "lang": "rust", "repo": "bagar0x60/sandsim", "path": "/src/model/sand_graph.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn successors(&self, source: NodeIndex) -> Successors { let first_outgoing_edge = self.nodes[source].first_outgoing_edge; Successors { graph: self, current_edge_index: first_outgoing_edge } } pub fn non_sink_nodes(&self) -> impl Iterator<Item = NodeIndex> { 1 .. s...
code_fim
hard
{ "lang": "rust", "repo": "bagar0x60/sandsim", "path": "/src/model/sand_graph.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn add_edge(&mut self, source: NodeIndex, target: NodeIndex, weight: i32) { let edge_index = self.edges.len(); let node_data = &mut self.nodes[source]; self.edges.push(EdgeData { weight: weight, target: target, next_outgoing_edge: node_da...
code_fim
hard
{ "lang": "rust", "repo": "bagar0x60/sandsim", "path": "/src/model/sand_graph.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: caibirdme/leetcode_rust path: /src/match_191/prob_5426.rs use std::collections::HashMap; impl Solution { pub fn min_reorder(n: i32, connections: Vec<Vec<i32>>) -> i32 { let mut ans = 0; let mut graph = HashMap::new(); let mut come_from = HashMap::new(); for e...
code_fim
hard
{ "lang": "rust", "repo": "caibirdme/leetcode_rust", "path": "/src/match_191/prob_5426.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> head += 1; if let Some(come) = come_from.get(&cur) { for &v in come { if !used[v as usize] { used[v as usize] = true; q.push(v); } } } if let So...
code_fim
hard
{ "lang": "rust", "repo": "caibirdme/leetcode_rust", "path": "/src/match_191/prob_5426.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KaiserY/trpl-zh-cn path: /listings/ch19-advanced-features/listing-19-07/src/main.rs fn main() { // ANCHOR: here use std::slice; <|fim_suffix|> let values: &[i32] = unsafe { slice::from_raw_parts_mut(r, 10000) }; // ANCHOR_END: here }<|fim_middle|> let address = 0x01234usize; ...
code_fim
medium
{ "lang": "rust", "repo": "KaiserY/trpl-zh-cn", "path": "/listings/ch19-advanced-features/listing-19-07/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let values: &[i32] = unsafe { slice::from_raw_parts_mut(r, 10000) }; // ANCHOR_END: here }<|fim_prefix|>// repo: KaiserY/trpl-zh-cn path: /listings/ch19-advanced-features/listing-19-07/src/main.rs fn main() { // ANCHOR: here use std::slice; <|fim_middle|> let address = 0x01234usize; ...
code_fim
medium
{ "lang": "rust", "repo": "KaiserY/trpl-zh-cn", "path": "/listings/ch19-advanced-features/listing-19-07/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[link(name = "zircon")] extern "C" { fn zx_deadline_after(nanoseconds: zx_duration_t) -> zx_time_t; fn zx_futex_wait( value_ptr: *mut zx_futex_t, current_value: zx_futex_t, deadline: zx_time_t, ) -> zx_status_t; fn zx_futex_wake(value_ptr: *const zx_futex_t, coun...
code_fim
hard
{ "lang": "rust", "repo": "pitdicker/valet_parking", "path": "/src/futex/fuchsia.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pitdicker/valet_parking path: /src/futex/fuchsia.rs #![allow(non_camel_case_types)] use core::sync::atomic::{AtomicI32, AtomicU32}; use core::time::Duration; use crate::futex::{Futex, WakeupReason}; use crate::utils::AtomicAsMutPtr; macro_rules! imp_futex { ($atomic_type:ident, $int_type:...
code_fim
hard
{ "lang": "rust", "repo": "pitdicker/valet_parking", "path": "/src/futex/fuchsia.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let ptr = self.as_mut_ptr() as *mut i32; let wake_count = u32::max_value(); let r = unsafe { zx_futex_wake(ptr, wake_count) }; debug_assert!( r == ZX_OK, "Unexpected return value of zx_futex_wake: {}", ...
code_fim
hard
{ "lang": "rust", "repo": "pitdicker/valet_parking", "path": "/src/futex/fuchsia.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> GqlRenderer::Type(GqlTypeRenderer::Output(self.clone())) } } impl<'a> AsRenderer<'a> for InputField<'a> { fn as_renderer(&self) -> GqlRenderer<'a> { GqlRenderer::Field(GqlFieldRenderer::Input(self.clone())) } } impl<'a> AsRenderer<'a> for OutputField<'a> { fn as_renderer(...
code_fim
hard
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/query-engine/request-handlers/src/protocols/graphql/schema_renderer/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl RenderContext { fn new() -> Self { RenderContext { output_queue: Default::default(), rendered: Default::default(), indent: 2, indent_str: " ", } } fn format(self) -> String { self.output_queue.join("\n\n") } ...
code_fim
hard
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/query-engine/request-handlers/src/protocols/graphql/schema_renderer/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let angle_increment = TAU / (self.num_faces as f32); let vertices = (0..self.num_faces) .map(|i| { let angle = angle_increment * i as f32; translation + uxy * Vec2::from_angle(angle) }); mb.extend_2d_fan(self.num_faces, vertices); } }<|fim_prefix|>// repo: manpat/imgui-playground pa...
code_fim
hard
{ "lang": "rust", "repo": "manpat/imgui-playground", "path": "/toybox-rs/src/gfx/mesh/geom_2d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if self.num_faces < 3 { return } let [ux, uy, translation] = self.basis.columns(); let uxy = Mat2::from_columns([ux/2.0, uy/2.0]); let angle_increment = TAU / (self.num_faces as f32); let vertices = (0..self.num_faces) .map(|i| { let angle = angle_increment * i as f32; translat...
code_fim
hard
{ "lang": "rust", "repo": "manpat/imgui-playground", "path": "/toybox-rs/src/gfx/mesh/geom_2d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: manpat/imgui-playground path: /toybox-rs/src/gfx/mesh/geom_2d.rs use common::*; use crate::gfx::mesh::{PolyBuilder2D, traits::BuildableGeometry2D}; pub struct Quad { basis: Mat2x3, } impl Quad { pub fn from_matrix(basis: Mat2x3) -> Quad { Quad {basis} } pub fn unit() -> Quad { Quad::...
code_fim
hard
{ "lang": "rust", "repo": "manpat/imgui-playground", "path": "/toybox-rs/src/gfx/mesh/geom_2d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let res = client .get("https://sso.yunaq.com/captcha/".parse()?) .await?; assert_eq!(res.status(), 200); let buf = hyper::body::to_bytes(res).await?; let mut file = File::create(format!("tests/demo_{}.png", number)).await?; ...
code_fim
hard
{ "lang": "rust", "repo": "apicode-group/apicode", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apicode-group/apicode path: /src/lib.rs pub mod model; pub use model::postman::*; pub mod plugins; #[cfg(test)] mod tests { // use super::*; use tokio::fs::File; use tokio::io::AsyncWriteExt; #[tokio::test] async fn test_java_lombok_dto_source_gen_async( ) -> Result<()...
code_fim
hard
{ "lang": "rust", "repo": "apicode-group/apicode", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } use hyper::Client; use hyper_tls::HttpsConnector; use std::thread; use std::time::Duration; #[tokio::test] async fn text() -> Result<(), Box<dyn std::error::Error>> { let mut number = 1; while number != 2 { let https = HttpsConnect...
code_fim
hard
{ "lang": "rust", "repo": "apicode-group/apicode", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Now check we can correctly deaggregate a multi-kernel tx based on current // contents of the txpool. // We will do this be adding a new tx to the pool // that is a superset of a tx already in the pool. { let tx4 = test_transaction(&keychain, vec![111], vec![77], &chain); // tx1 and tx2 are al...
code_fim
hard
{ "lang": "rust", "repo": "hagridthegreat37/bitcoinmw", "path": "/pool/tests/transaction_pool.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hagridthegreat37/bitcoinmw path: /pool/tests/transaction_pool.rs // Copyright 2020 The Grin Developers // // 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 // // ht...
code_fim
hard
{ "lang": "rust", "repo": "hagridthegreat37/bitcoinmw", "path": "/pool/tests/transaction_pool.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn create_percentage_print_reporter(message: &str, step: u32) -> ProgressReporter<'static> { assert!(step <= 100); let current = Arc::new(AtomicIsize::new(-100)); let message = message.to_owned(); ProgressReporter::new(move |checkpoint| { if let Some(remaining) = checkpoint.re...
code_fim
hard
{ "lang": "rust", "repo": "shnwang/elfshaker", "path": "/src/bin/elfshaker/utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shnwang/elfshaker path: /src/bin/elfshaker/utils.rs //! SPDX-License-Identifier: Apache-2.0 //! Copyright (C) 2021 Arm Limited or its affiliates and Contributors. All rights reserved. use elfshaker::log::measure; use elfshaker::progress::ProgressReporter; use elfshaker::repo::{Error as RepoErro...
code_fim
hard
{ "lang": "rust", "repo": "shnwang/elfshaker", "path": "/src/bin/elfshaker/utils.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> return false; } fn iter_nodes<'a>( self: Pin<&'a mut Self>, ) -> impl PinIterator<Item = Pin<&'a mut Node<T>>> + 'a { gen_iter! { let mut node = unsafe { Pin::get_unchecked_mut(self).head }; while node != ptr::null_mut() { yield ...
code_fim
hard
{ "lang": "rust", "repo": "Nemo157/pin-collections-rs", "path": "/src/list.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nemo157/pin-collections-rs path: /src/list.rs use { core::{pin::Pin, ptr}, pin_project::unsafe_project, ergo_pin::ergo_pin, }; use crate::{gen_iter, PinIterator}; #[unsafe_project] pub struct List<T> { head: *mut Node<T>, } #[unsafe_project] pub struct Node<T> { next: *mut...
code_fim
hard
{ "lang": "rust", "repo": "Nemo157/pin-collections-rs", "path": "/src/list.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let this = self.project(); if *this.attached { panic!("node attached while still attached to another list"); } *this.attached = true; } fn on_detached(self: Pin<&mut Self>) { let this = self.project(); if !*this.attached { pa...
code_fim
hard
{ "lang": "rust", "repo": "Nemo157/pin-collections-rs", "path": "/src/list.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>let token = if using_cached_token { + let cached_token = self.input.cached_token.as_ref().unwrap(); + self.input.tokenizer.reset(&cached_token.end_state); + match cached_token.token { + Token::Function(ref name) => self.input.tokenizer.see_function(name), + ...
code_fim
hard
{ "lang": "rust", "repo": "fidelix-project/pkgsrc", "path": "/www/firefox60/patches/patch-third__party_rust_cssparser_src_parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fidelix-project/pkgsrc path: /www/firefox60/patches/patch-third__party_rust_cssparser_src_parser.rs $NetBSD: patch-third__party_rust_cssparser_src_parser.rs,v 1.1 2019/12/28 05:48:06 ryoon Exp $ * Partially backport for rust-1.39.0 from https://phabricator.services.mozilla.com/D47796 --- thi...
code_fim
hard
{ "lang": "rust", "repo": "fidelix-project/pkgsrc", "path": "/www/firefox60/patches/patch-third__party_rust_cssparser_src_parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> .map_err(|()| self.new_basic_error(BasicParseErrorKind::EndOfInput))?; self.input.cached_token = Some(CachedToken { token: new_token, start_position: token_start_position, end_state: self.input.tokenizer.st...
code_fim
hard
{ "lang": "rust", "repo": "fidelix-project/pkgsrc", "path": "/www/firefox60/patches/patch-third__party_rust_cssparser_src_parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mbandazian/cs4414 path: /ps1/src/splitter.rs use std::rand::random; use std::os; use std::io::File; fn main() { let args = os::args(); if args.len() != 2 { println!("Usage: {} <inputfile>", args[0]); } else { let fname = args[1].clone(); let path = Path::new...
code_fim
hard
{ "lang": "rust", "repo": "mbandazian/cs4414", "path": "/ps1/src/splitter.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut random_bytes: Vec<u8> = vec![]; // This is not cryptographically strong randomness! // (For entertainment purposes only.) for _ in range(0, msg_bytes.len()) { let random_byte = random(); random_bytes.push(random_byte); } let encrypted_bytes = xor(&msg_bytes, &rand...
code_fim
medium
{ "lang": "rust", "repo": "mbandazian/cs4414", "path": "/ps1/src/splitter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: edualb/utils path: /rust/enums/src/main.rs enum IpAddreKind { V4, V6, } fn main() { println!("Hello, world!"); } // Instantiate enums fn instantiate_enums() { let four = IpAddreKind::V4; let six = IpAddreKind::V6; } // Definig function with enums fn defining_functions(ip_k...
code_fim
hard
{ "lang": "rust", "repo": "edualb/utils", "path": "/rust/enums/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match value { 1 => println!("one"), 3 => println!("three"), 5 => println!("five"), 7 => println!("seven"), _ => (), } } // Concise Control Flow with if let fn concise_control_flow_with_if_let() { let some_u8_value = Some(0u8); // match some_u8_val...
code_fim
hard
{ "lang": "rust", "repo": "edualb/utils", "path": "/rust/enums/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luckyyang/graph-node path: /graphql/src/schema/ext.rs use graphql_parser::schema as s; pub trait ObjectTypeExt { fn field(&self, name: &s::Name) -> Option<&s::Field>; } <|fim_suffix|> self.fields.iter().find(|field| &field.name == name) } }<|fim_middle|>impl ObjectTypeExt for s:...
code_fim
hard
{ "lang": "rust", "repo": "luckyyang/graph-node", "path": "/graphql/src/schema/ext.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl ObjectTypeExt for s::InterfaceType { fn field(&self, name: &s::Name) -> Option<&s::Field> { self.fields.iter().find(|field| &field.name == name) } }<|fim_prefix|>// repo: luckyyang/graph-node path: /graphql/src/schema/ext.rs use graphql_parser::schema as s; pub trait ObjectTypeExt {...
code_fim
medium
{ "lang": "rust", "repo": "luckyyang/graph-node", "path": "/graphql/src/schema/ext.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/code-festival-2014-quala/src/bin/c.rs use proconio::input; fn main() { input! { a: i64, b: i64, }; let a = a - 1; let count_a = a / <|fim_suffix|>400; let ans = count_b - count_a; println!("{}", ans); }<|...
code_fim
medium
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/code-festival-2014-quala/src/bin/c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>400; let ans = count_b - count_a; println!("{}", ans); }<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/code-festival-2014-quala/src/bin/c.rs use proconio::input; fn main() { input! { a: i64, <|fim_middle|> b: i64, }; let a = a - 1; let co...
code_fim
medium
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/code-festival-2014-quala/src/bin/c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut message = String::new(); message.push_str("options: \n"); message.push_str("\t-host: server listen ip, exp: 0.0.0.0\n"); message.push_str("\t-port: server listen port, exp: 50005\n"); message.push_str("\t-thread-max: thread max number, exp: 10\n"); message.push_str("\t...
code_fim
medium
{ "lang": "rust", "repo": "MwlLj/rust-debugging", "path": "/log_server/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut cmdHandler = CCmd::new(); let host = cmdHandler.register(argServerHost, "0.0.0.0"); let port = cmdHandler.register(argServerPort, "50005"); let maxDay = cmdHandler.register(argMaxDay, "5"); let threadMax = cmdHandler.register(argThreadMax, "10"); cmdHandler.parse(); ...
code_fim
medium
{ "lang": "rust", "repo": "MwlLj/rust-debugging", "path": "/log_server/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MwlLj/rust-debugging path: /log_server/src/main.rs extern crate rust_parse; extern crate log_server; use std::rc::Rc; use log_server::dispatch::connect; use rust_parse::cmd::CCmd; const argServerHost: &str = "-host"; const argServerPort: &str = "-port"; const argThreadMax: &str = "-...
code_fim
hard
{ "lang": "rust", "repo": "MwlLj/rust-debugging", "path": "/log_server/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rectinajh/rust-leetcode path: /src/l226_invert_binary_tree.rs /* 226. 翻转二叉树 翻转一棵二叉树。 示例: 输入: ``` 4 / \ 2 7 / \ / \ 1 3 6 9 输出: 4 / \ 7 2 / \ / \ 9 6 3 1 ``` 备注: 这个问题是受到 Max Howell 的 原问题 启发的 : <|fim_suffix|>来源:力扣(LeetCode) 链接:https://leetcode-cn....
code_fim
medium
{ "lang": "rust", "repo": "rectinajh/rust-leetcode", "path": "/src/l226_invert_binary_tree.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( Solution::invert_tree(build_tree(&vec![3, 9, 20, NULL, NULL, 15, 7])), build_tree(&vec![3, 20, 9, 7, 15]) ); } }<|fim_prefix|>// repo: rectinajh/rust-leetcode path: /src/l226_invert_binary_tree.rs /* 226. 翻转二叉树 翻转一棵二叉树。 示例: 输入: ``` 4 / ...
code_fim
hard
{ "lang": "rust", "repo": "rectinajh/rust-leetcode", "path": "/src/l226_invert_binary_tree.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn prepare_ton_event_payload( address: &MsgAddressInt, details: &TonEventConfiguration, event: &SwapBackEvent, ) -> Result<Vec<u8>, Error> { // struct TONEvent { // uint eventTransaction; // uint64 eventTransactionLt; // uint32 eventTimestamp; // uint32 ...
code_fim
hard
{ "lang": "rust", "repo": "howl111/ton-eth-bridge-relay", "path": "/src/engine/bridge/utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: howl111/ton-eth-bridge-relay path: /src/engine/bridge/utils.rs bool") => EthParamType::Bool, str if str.starts_with("string") => EthParamType::String, str if str.starts_with("bytes") => { let num = str.trim_start_matches(char::is_alphabetic).parse()?; EthP...
code_fim
hard
{ "lang": "rust", "repo": "howl111/ton-eth-bridge-relay", "path": "/src/engine/bridge/utils.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: howl111/ton-eth-bridge-relay path: /src/engine/bridge/utils.rs } (EthTokenValue::Int(x), &EthParamType::Int(size)) => { let mut bytes = [0u8; 256 / 8]; x.to_big_endian(&mut bytes); let number = BigInt::from_signed_bytes_be(&bytes); To...
code_fim
hard
{ "lang": "rust", "repo": "howl111/ton-eth-bridge-relay", "path": "/src/engine/bridge/utils.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>MyPhantomPinned { } impl ! Unpin for MyPhantomPinned { } impl Unpin for Foo < MyPhantomPinned ( ) > { } fn is_unpin < T : Unpin > ( ) { } fn main ( ) { is_unpin : : < Foo < MyPhantomPinned ( ) > > ( ) }<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/pin-pro...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/pin-project/tests/ui/unstable-features/negative_impls.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_from() { assert_eq!(Sexp::Atom(Atom::UInt(123)), Sexp::from(123u64)); assert_eq!(Sexp::Atom(Atom::SInt(123)), Sexp::from(123i64)); assert_eq!( Sexp::Atom(Atom::Str("test".to_string())), Sexp::from("test") ); assert_eq!(Sexp::Atom(Atom::Float(123.45)), Se...
code_fim
hard
{ "lang": "rust", "repo": "mneumann/asexp-rs", "path": "/src/sexp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mneumann/asexp-rs path: /src/sexp.rs use super::atom::Atom; use super::parser; use super::token::{Token, Tokenizer}; use std::collections::BTreeMap; use std::fmt; use std::io; #[derive(Debug, PartialEq, Clone)] pub enum Sexp { Atom(Atom), // ( ... ) Tuple(Vec<Sexp>), // [ ... ...
code_fim
hard
{ "lang": "rust", "repo": "mneumann/asexp-rs", "path": "/src/sexp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if newline { write!(f, "\n")?; for _ in 0..cmp::min(8, indent) { write!(f, "{:>4}", "")?; } } match *sexp { Sexp::Atom(ref a) => write!(f, "{}", a), Sexp::Tuple(ref t) => { write!(f, "(")?; for (i, expr) in t.iter().e...
code_fim
hard
{ "lang": "rust", "repo": "mneumann/asexp-rs", "path": "/src/sexp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lumost/native_spark path: /src/error.rs use std::ffi::OsString; use std::path::PathBuf; use thiserror::Error; pub type Result<T> = std::result::Result<T, Error>; pub type StdResult<T, E> = std::result::Result<T, E>; #[derive(Debug, Error)] pub enum Error { #[error("async runtime configura...
code_fim
hard
{ "lang": "rust", "repo": "lumost/native_spark", "path": "/src/error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[error(transparent)] ShuffleError(#[from] crate::shuffle::ShuffleError), #[error("operation not supported: {0}")] UnsupportedOperation(&'static str), } impl Error { pub(crate) fn executor_shutdown(&self) -> bool { match self { Error::ExecutorShutdown => true, ...
code_fim
hard
{ "lang": "rust", "repo": "lumost/native_spark", "path": "/src/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[error("operation not supported: {0}")] UnsupportedOperation(&'static str), } impl Error { pub(crate) fn executor_shutdown(&self) -> bool { match self { Error::ExecutorShutdown => true, _ => false, } } } #[derive(Debug, Error)] pub enum NetworkErr...
code_fim
hard
{ "lang": "rust", "repo": "lumost/native_spark", "path": "/src/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub use dopri5::Dopri5; pub use dop853::Dop853; pub use dop_shared::System;<|fim_prefix|>// repo: rolveb/ode-solvers path: /src/lib.rs //! # ODEs Solvers //! `ode-solvers` is a collection of numerical methods to solve ordinary differential equations (ODEs). // Re-export from external crate use nalgebra...
code_fim
medium
{ "lang": "rust", "repo": "rolveb/ode-solvers", "path": "/src/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rolveb/ode-solvers path: /src/lib.rs //! # ODEs Solvers //! `ode-solvers` is a collection of numerical methods to solve ordinary differential equations (ODEs). // Re-export from external crate use nalgebra as na; pub use crate::na::{Vector1, Vector2, Vector3, Vector4, Vector5, Vector6, VectorN}...
code_fim
medium
{ "lang": "rust", "repo": "rolveb/ode-solvers", "path": "/src/lib.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let count = sample.chars().count(); // individual characters let mut chars = sample.chars(); let mut indiv_char = chars.next(); loop { match indiv_char { Some(expr) => println!("{}", expr), None => break, } indiv_char = chars.next(); } println!( ); // individual words let mut words...
code_fim
hard
{ "lang": "rust", "repo": "addictedcoder0/Rusty", "path": "/RustProg/StringExample/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: addictedcoder0/Rusty path: /RustProg/StringExample/src/main.rs fn string_utf8(k:&str){ for b in k.as_bytes(){ print!("{},",b); } println!(""); for c in k.chars(){ print!("{},",c); } println!(""); //for accessing individual char use //chars().nth(x)=>Option(). println!("1st char is ...
code_fim
hard
{ "lang": "rust", "repo": "addictedcoder0/Rusty", "path": "/RustProg/StringExample/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // 41 comes from RSA_public_encrypt(3) for OAEP assert s.len() < libcrypto::RSA_size(rsa) as uint - 41u; let mut r = vec::from_elem(len as uint + 1u, 0u8); do vec::as_mut_buf(r) |pr, _len| { do vec::as_imm_buf(s) |ps, s_len| { // XXX: 4 == RSA_...
code_fim
hard
{ "lang": "rust", "repo": "brson/rustcrypto", "path": "/pkey.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if rv < 0 as c_int { ~[] } else { vec::slice(r, 0u, *plen as uint) } } } } /** * Verifies a signature s (using OpenSSL's default scheme and sha256) on a * message m. Returns true ...
code_fim
hard
{ "lang": "rust", "repo": "brson/rustcrypto", "path": "/pkey.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brson/rustcrypto path: /pkey.rs use libc::{c_int, c_uint}; #[allow(non_camel_case_types)] type EVP_PKEY = *libc::c_void; #[allow(non_camel_case_types)] type ANYKEY = *libc::c_void; #[allow(non_camel_case_types)] type RSA = *libc::c_void; #[link_name = "crypto"] #[abi = "cdecl"] extern mod li...
code_fim
hard
{ "lang": "rust", "repo": "brson/rustcrypto", "path": "/pkey.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let msg = wsio.next().await; let result = msg.expect_throw( "Stream closed" ); assert_eq!( WsMessage::Text( message ), result ); } // Verify that a round trip to an echo server generates identical binary data. // #[ wasm_bindgen_test(async) ] // async fn round_trip_binary() { let _ = console_lo...
code_fim
hard
{ "lang": "rust", "repo": "limira/ws_stream_wasm", "path": "/tests/ws_io.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: limira/ws_stream_wasm path: /tests/ws_io.rs wasm_bindgen_test_configure!(run_in_browser); // What's tested: // // Tests send to an echo server which just bounces back all data. // // ✔ Send a WsMessage::Text and verify we get an identical WsMessage back. // ✔ Send a WsMessage::Binary and ve...
code_fim
hard
{ "lang": "rust", "repo": "limira/ws_stream_wasm", "path": "/tests/ws_io.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let (mut ws, mut wsio) = WsStream::connect( URL, None ).await.expect_throw( "Could not create websocket" ); let mut evts = ws.observe( ObserveConfig::default() ).expect( "observe" ); AsyncWriteExt::close( &mut wsio ).await.expect_throw( "close ws" ); assert!( evts.next().await.unwrap_throw().is_clo...
code_fim
hard
{ "lang": "rust", "repo": "limira/ws_stream_wasm", "path": "/tests/ws_io.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: erikkurcz/learning_rust path: /hello.rs // Basic hello world program fn main(){ // printing via macro println!("Hello world!"); println!("I'm a Rustacean!"); <|fim_suffix|> eprint!("Error text, pipe to see"); eprintln!("Error newline, pipe to see"); // More st...
code_fim
medium
{ "lang": "rust", "repo": "erikkurcz/learning_rust", "path": "/hello.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Suffixes println!("{} of {:b} people know binary, the other half doesn't", 1, 2); println!("My name is {0}, {1} {0}", "Bond", "James"); // Number formatting let pi = 3.14159; println!("Pi is equal to: {1:.*}", 3, pi); }<|fim_prefix|>// repo: erikkurcz/learning_rust path:...
code_fim
hard
{ "lang": "rust", "repo": "erikkurcz/learning_rust", "path": "/hello.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>{ // Load arguments from the current script. let script = load_script()?; let args = script.args(); // Verify that the minimum length of the arguments was given. if args.len() < ARGS_LEN { return Err(Error::ArgsLen); } // If program is in owner mode then unlock immediately. if check_owner_mod...
code_fim
hard
{ "lang": "rust", "repo": "jordanmack/token-sale", "path": "/contracts/token-sale/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jordanmack/token-sale path: /contracts/token-sale/src/main.rs //! Simple Token Sale Lock Script //! https://github.com/jordanmack/token-sale //! //! A simple Lock Script for handling the sale of SUDT tokens for CKBytes on Nervos CKB. //! The Lock Script can be added to any SUDT Cell to enable a...
code_fim
hard
{ "lang": "rust", "repo": "jordanmack/token-sale", "path": "/contracts/token-sale/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>{ let lock_script_bytes = &lock_script.as_bytes()[..]; let type_script_bytes = &type_script.as_bytes()[..]; // Loop through all the output Cells. let mut i = 0; let mut token_sale_lock_cells = 0; loop { let cell = match load_cell(i, Source::Output) { Ok(cell) => cell, Err(SysError::Index...
code_fim
hard
{ "lang": "rust", "repo": "jordanmack/token-sale", "path": "/contracts/token-sale/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ruza-net/miful path: /src/parsing/ast.rs use std::fmt::{ self, Formatter, Display }; fn format_node(node: &NodeKind, hooks: &Vec<NodeWrapper>, layer: usize, include_initial_indent: bool) -> String { let indent = " ".repeat(layer).to_owned(); let mut output; if include_initial_in...
code_fim
hard
{ "lang": "rust", "repo": "ruza-net/miful", "path": "/src/parsing/ast.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new_hook(v_idx: usize, hooks: Vec<NodeWrapper>, index: usize, position: (usize, usize)) -> NodeWrapper { NodeWrapper { node: NodeKind::LambdaHook(v_idx), hooks,// [NOTE] Not nested hooks, just the contained value. position, index, ...
code_fim
hard
{ "lang": "rust", "repo": "ruza-net/miful", "path": "/src/parsing/ast.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> position, index, } } pub fn new_symbol(value: String, index: usize, position: (usize, usize)) -> NodeWrapper { NodeWrapper { node: NodeKind::Symbol(value.to_owned()), hooks: vec![], position, index, }...
code_fim
hard
{ "lang": "rust", "repo": "ruza-net/miful", "path": "/src/parsing/ast.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> populate_results_store(&results, &results_store); } })); // --- // --- Display events on click let selected_event_id_label: gtk::Label = builder .get_object("current-event-id") .expect("current-event-id"); let selected_event_id_copy: gtk::Button =...
code_fim
hard
{ "lang": "rust", "repo": "repositive/event-store-rs", "path": "/explorer/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: repositive/event-store-rs path: /explorer/src/main.rs // enable the await! macro, async support, and the new std::Futures api. #![feature(await_macro, async_await)] // only needed to manually implement a std future: #![feature(arbitrary_self_types)] #[macro_use] mod macros; use chrono::prelude...
code_fim
hard
{ "lang": "rust", "repo": "repositive/event-store-rs", "path": "/explorer/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> add_column(&results_list, "text", "ID", ResultColumn::Id); add_column(&results_list, "text", "Data", ResultColumn::Data); add_column(&results_list, "text", "Context", ResultColumn::Context); results_list.set_headers_visible(true); results_list.set_model(Some(&results_store)); // ...
code_fim
hard
{ "lang": "rust", "repo": "repositive/event-store-rs", "path": "/explorer/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn it_detects_open() { assert_eq!(Feature::Open, kind((1,1), 10)); } #[test] fn it_generates_possible_neighbours() { let output = vec![ Step { loc: (3, 3), distance: 1}, Step { loc: (4, 2), distance: 1}, Step { loc: (3, 1), d...
code_fim
hard
{ "lang": "rust", "repo": "tahnok/advent2016", "path": "/src/bin/day13_2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tahnok/advent2016 path: /src/bin/day13_2.rs use std::collections::VecDeque; use std::collections::HashSet; fn main() { // let dest = (31, 39); let fav_number = 1350; let steps = 50; println!("{}", max_loc_visited(steps, fav_number)); } #[derive(Debug, PartialEq)] pub enum Feat...
code_fim
hard
{ "lang": "rust", "repo": "tahnok/advent2016", "path": "/src/bin/day13_2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // pwritev them into a temporary file let path = tempdir.path().join("pwritev_test_file"); let mut file = OpenOptions::new() .write(true) .read(true) .create(true) .truncate(true) .open(path) .unwrap(); let written = pwritev(&file, &iovecs, ...
code_fim
hard
{ "lang": "rust", "repo": "nix-rust/nix", "path": "/test/sys/test_uio.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> { // Borrow the buffers into IoVecs and preadv into them let mut iovecs: Vec<_> = buffers .iter_mut() .map(|buf| IoSliceMut::new(&mut buf[..])) .collect(); assert_eq!(Ok(100), preadv(&file, &mut iovecs, 100)); } let all = buffers.con...
code_fim
hard
{ "lang": "rust", "repo": "nix-rust/nix", "path": "/test/sys/test_uio.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nix-rust/nix path: /test/sys/test_uio.rs use nix::sys::uio::*; use nix::unistd::*; use rand::distributions::Alphanumeric; use rand::{thread_rng, Rng}; use std::fs::OpenOptions; use std::io::IoSlice; use std::os::unix::io::{FromRawFd, OwnedFd}; use std::{cmp, iter}; #[cfg(not(target_os = "redox"...
code_fim
hard
{ "lang": "rust", "repo": "nix-rust/nix", "path": "/test/sys/test_uio.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adrianloh/rustyone path: /src/bin/struct_basic.rs // `Copy` allows the struct to be passed by value or reassigned // `Clone` allows `.clone()` and _must_ be implemented to allow `Copy` // `PartialEq` allows us to `==` or `!=` between `Point`s since all fields of `Point` are comparable #[der...
code_fim
medium
{ "lang": "rust", "repo": "adrianloh/rustyone", "path": "/src/bin/struct_basic.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut points_copies: Vec<Point> = Vec::new(); let mut points_clones: Vec<Point> = Vec::new(); points.iter().for_each(|point /* &Point */| { // `Copy` allows us to... let pp1 = *point; // dereference _and_ move `*point` into `pp1`, again copying it let pp2 = pp1; ...
code_fim
hard
{ "lang": "rust", "repo": "adrianloh/rustyone", "path": "/src/bin/struct_basic.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Point { fn new(x: f64, y: f64) -> Self { // Constructor Point { x, y } } fn magnitude(&self) -> f64 { // Using `&` since we just need a read-only ref to self let xsq = self.x * self.x; let ysq = self.y * self.y; (xsq + ysq).sqrt() ...
code_fim
medium
{ "lang": "rust", "repo": "adrianloh/rustyone", "path": "/src/bin/struct_basic.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lenoil98/basic_rs path: /src/relooper/tests.rs use matches::*; use quickcheck::*; use super::*; impl Shape { fn find_child_shape(&self, shape_id: ShapeId) -> Option<&Shape> { if self.id == shape_id { return Some(self); } match &self.kind { S...
code_fim
hard
{ "lang": "rust", "repo": "lenoil98/basic_rs", "path": "/src/relooper/tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }