text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: xiongxin/rust_sqlite path: /src/sql/parser/create.rs use sqlparser::ast::{ColumnOption, DataType, ObjectName, Statement}; use crate::error::{SQLRiteError, Result}; // Represents Columns in a table #[derive(PartialEq, Debug)] pub struct ParsedColumn { pub name: String, pub datatype: Str...
code_fim
hard
{ "lang": "rust", "repo": "xiongxin/rust_sqlite", "path": "/src/sql/parser/create.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tawawhite/tract path: /linalg/matmul-bench/benches/matmul.rs #![allow(non_snake_case)] #[cfg(feature = "blis")] extern crate blis_src; #[cfg(feature = "blis")] extern crate cblas; #[cfg(feature = "accelerate")] extern crate accelerate_src; use criterion::measurement::WallTime; use criterion::*;...
code_fim
hard
{ "lang": "rust", "repo": "tawawhite/tract", "path": "/linalg/matmul-bench/benches/matmul.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn tract(crit: &mut BenchmarkGroup<WallTime>, m: usize, k: usize, n: usize) { let a = Tensor::zero_dt(DatumType::F32, &[m, k]).unwrap(); let b = Tensor::zero_dt(DatumType::F32, &[k, n]).unwrap(); let mut c = Tensor::zero_dt(DatumType::F32, &[n, m]).unwrap(); unsafe { crit.bench_fu...
code_fim
hard
{ "lang": "rust", "repo": "tawawhite/tract", "path": "/linalg/matmul-bench/benches/matmul.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn matmul(c: &mut Criterion, m: usize, k: usize, n: usize) { let mut c = c.benchmark_group(format!("{}x{}x{}", m, k, n)); c.throughput(Throughput::Elements((m * k * n) as _)); naive(&mut c, m, k, n); tile_2x2(&mut c, m, k, n); matrixmultiply(&mut c, m, k, n); cblas(&mut c, m, k, n)...
code_fim
hard
{ "lang": "rust", "repo": "tawawhite/tract", "path": "/linalg/matmul-bench/benches/matmul.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paritytech/substrate path: /utils/frame/benchmarking-cli/src/shared/weight_params.rs // This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use th...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/utils/frame/benchmarking-cli/src/shared/weight_params.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod test_weight_params { use super::WeightParams; use crate::shared::{StatSelect, Stats}; #[test] fn calc_weight_works() { let stats = Stats { avg: 113, ..Default::default() }; let params = WeightParams { weight_metric: StatSelect::Average, weight_mul: 0.75, weight_add: 3, ...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/utils/frame/benchmarking-cli/src/shared/weight_params.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let stats = Stats { avg: 113, ..Default::default() }; let params = WeightParams { weight_metric: StatSelect::Average, weight_mul: 0.75, weight_add: 3, ..Default::default() }; let want = (113.0f64 * 0.75 + 3.0).ceil() as u64; // Ceil for overestimation. let got = params.calc_weight(&...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/utils/frame/benchmarking-cli/src/shared/weight_params.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Lalcs/jpholiday-rust path: /src/holidays.rs use super::chrono::{Datelike, NaiveDate, Weekday, Duration}; use super::utils::{week_day}; use std::borrow::Borrow; use super::registry::Registry; use dyn_clone::DynClone; use std::ops::Add; pub trait Holiday: DynClone { fn is_holiday(&self, date:...
code_fim
hard
{ "lang": "rust", "repo": "Lalcs/jpholiday-rust", "path": "/src/holidays.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Holiday for ConstitutionMemorialDay { fn exists_holiday(&self, date: &NaiveDate) -> bool { if date.month() == 5 && date.day() == 3 { return true; } return false; } fn resolve_holiday_name(&self, _date: &NaiveDate) -> String { "憲法記念日".to_string(...
code_fim
hard
{ "lang": "rust", "repo": "Lalcs/jpholiday-rust", "path": "/src/holidays.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if date.month() == 11 && date.day() == 23 { return true; } return false; } fn resolve_holiday_name(&self, _date: &NaiveDate) -> String { "勤労感謝の日".to_string() } } // 皇室慶弔行事に伴う祝日 #[derive(Clone)] pub struct ExtraHolidays {} impl ExtraHolidays { ...
code_fim
hard
{ "lang": "rust", "repo": "Lalcs/jpholiday-rust", "path": "/src/holidays.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Recognize a closing parenthesis. fn right_paren(input: Input) -> IResult<char> { lexeme(char(')'))(input) } /// Recognize an opening bracket. fn left_bracket(input: Input) -> IResult<char> { lexeme(char('['))(input) } /// Recognize a closing bracket. fn right_bracket(input: Input) -> IResult...
code_fim
hard
{ "lang": "rust", "repo": "plorefice/dtls", "path": "/dts-parser/src/ast/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let errs = RefCell::default(); let s = Span::new_extra(input.as_bytes(), State(&errs)); assert_eq!(exp, all_consuming(root)(s).unwrap().1,); } #[test] fn parse_ternary_operator() { let input = r#" ( (35 <= 2) ? (0x00b4 + 4 * 35) : ...
code_fim
hard
{ "lang": "rust", "repo": "plorefice/dtls", "path": "/dts-parser/src/ast/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: plorefice/dtls path: /dts-parser/src/ast/parser.rs trings() { for (input, exp) in [(r#""Escaped string: \"\\\"""#, r#"Escaped string: \"\\\""#)] { let errs = RefCell::default(); let s = Span::new_extra(input.as_bytes(), State(&errs)); assert_eq!( ...
code_fim
hard
{ "lang": "rust", "repo": "plorefice/dtls", "path": "/dts-parser/src/ast/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: masinc/coreutils-rs path: /echo/src/lib.rs use itertools::Itertools; use std::fmt::Display; pub fn parse_strings(strings: &mut impl Iterator<Item = impl Into<String> + Display>) -> String { strings.join(" ") } #[cfg(test)] mod tests { use super::*; #[test] fn test_parse_strings...
code_fim
hard
{ "lang": "rust", "repo": "masinc/coreutils-rs", "path": "/echo/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( parse_strings(&mut vec!["100", "200"].into_iter()), String::from("100 200") ); } }<|fim_prefix|>// repo: masinc/coreutils-rs path: /echo/src/lib.rs use itertools::Itertools; use std::fmt::Display; pub fn parse_strings(strings: &mut impl Iterator<It...
code_fim
hard
{ "lang": "rust", "repo": "masinc/coreutils-rs", "path": "/echo/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(parse_strings(&mut vec![""].into_iter()), String::from("")); assert_eq!( parse_strings(&mut vec!["1", "2"].into_iter()), String::from("1 2") ); assert_eq!( parse_strings(&mut vec!["100", "200"].into_iter()), String...
code_fim
medium
{ "lang": "rust", "repo": "masinc/coreutils-rs", "path": "/echo/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while let Ok(game_command) = rx.try_recv() { match (&game_command, &self.connection, &mut self.gamestate) { (&GameCommand { a: Some(ref a), .. }, ref con, ref mut _gamestate) => { match _gamestate { GameSta...
code_fim
hard
{ "lang": "rust", "repo": "alanpoon/rsrl", "path": "/rsrl_server/src/game_logic/game_engine.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alanpoon/rsrl path: /rsrl_server/src/game_logic/game_engine.rs use crate::game_logic; use rsrl_codec::*; use std::sync::mpsc; pub trait GameCon { fn tx_send(&self, msg: ClientReceivedMsg, log: &mut Vec<ClientReceivedMsg>); } pub struct GameEngine<T: GameCon> { connection: T, gamestat...
code_fim
hard
{ "lang": "rust", "repo": "alanpoon/rsrl", "path": "/rsrl_server/src/game_logic/game_engine.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if options.dry_run { options .config .shell() .warn("aborting remove due to dry run")?; } else { manifest.write()?; } Ok(()) }<|fim_prefix|>// repo: rust-lang/cargo path: /src/cargo/ops/cargo_remove.rs //! Core of cargo-remove command ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/cargo", "path": "/src/cargo/ops/cargo_remove.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/cargo path: /src/cargo/ops/cargo_remove.rs //! Core of cargo-remove command use crate::core::Package; use crate::util::toml_mut::manifest::DepTable; use crate::util::toml_mut::manifest::LocalManifest; use crate::CargoResult; use crate::Config; /// Remove a dependency from a Cargo.tom...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/cargo", "path": "/src/cargo/ops/cargo_remove.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crypto-com/jellyfish-merkle-tree path: /devtools/x-lint/src/project.rs // Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 <|fim_suffix|> /// Returns the project root. pub fn project_root(&self) -> &'l Path { self.project_root } /// Return...
code_fim
hard
{ "lang": "rust", "repo": "crypto-com/jellyfish-merkle-tree", "path": "/devtools/x-lint/src/project.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the project root. pub fn project_root(&self) -> &'l Path { self.project_root } /// Returns the absolute path from the project root. pub fn full_path(&self, path: impl AsRef<Path>) -> PathBuf { self.project_root.join(path.as_ref()) } } impl<'l> LintCont...
code_fim
hard
{ "lang": "rust", "repo": "crypto-com/jellyfish-merkle-tree", "path": "/devtools/x-lint/src/project.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, con: &mut Context, actors: &ActorMap, // actors before the move start: Pos, dir: Dir, color: Color, killed_id: ActorId, av: usize, // in [0, 8] ) -> Result<()> { let dst = start.in_dir(dir); if av%2==1 { ...
code_fim
hard
{ "lang": "rust", "repo": "Canop/lapin", "path": "/src/display/animate.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Canop/lapin path: /src/display/animate.rs use { anyhow::Result, crate::{ app::Context, core::*, pos::*, }, crossterm::{ cursor, style::{ Attributes, Color, ContentStyle, PrintStyledContent, ...
code_fim
hard
{ "lang": "rust", "repo": "Canop/lapin", "path": "/src/display/animate.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn is_syntactic_keyword(name: &str) -> bool { match name.len() { 2 => one_of!(name, [IF, OR, ARROW, DO]), 3 => one_of!(name, [AND, LET]), 4 => one_of!(name, [ELSE, SET_BANG, COND, CASE, LET_STAR]), 5 => one_of!(name, [QUOTE, BEGIN, DELAY]), 6 => one_of!(name...
code_fim
medium
{ "lang": "rust", "repo": "jrvidal/r5.rs", "path": "/src/compiler/keywords.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jrvidal/r5.rs path: /src/compiler/keywords.rs pub const IF: &str = "if"; pub const OR: &str = "or"; pub const ARROW: &str = "=>"; pub const DO: &str = "do"; pub const AND: &str = "and"; pub const LET: &str = "let"; pub const ELSE: &str = "else"; pub const SET_BANG: &str = "set!"; pub const COND:...
code_fim
medium
{ "lang": "rust", "repo": "jrvidal/r5.rs", "path": "/src/compiler/keywords.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ciusji/ferris path: /src/example/std_libs/rc.rs // Copyright 2021 Ferris Project Authors. License user Apache License. // Rc // When multiple ownership is needed, Rc (Reference Counting) can be used. Rc keeps track of the // number of the references which means the number of owners of the value...
code_fim
hard
{ "lang": "rust", "repo": "ciusji/ferris", "path": "/src/example/std_libs/rc.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Error! // `rc_examples` already moved into `rc-a` // and when `rc_a` is dropped, `rc_examples` is dropped together // println!("{}", rc_examples); }<|fim_prefix|>// repo: ciusji/ferris path: /src/example/std_libs/rc.rs // Copyright 2021 Ferris Project Authors. License user Apache Lice...
code_fim
hard
{ "lang": "rust", "repo": "ciusji/ferris", "path": "/src/example/std_libs/rc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!("--- rc_a is dropped out of scope ---"); } // Error! // `rc_examples` already moved into `rc-a` // and when `rc_a` is dropped, `rc_examples` is dropped together // println!("{}", rc_examples); }<|fim_prefix|>// repo: ciusji/ferris path: /src/example/std_libs/rc.rs /...
code_fim
medium
{ "lang": "rust", "repo": "ciusji/ferris", "path": "/src/example/std_libs/rc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Srynetix/gdpm path: /crates/gdpm-downloader/src/lib.rs //! Downloader crate. #![warn(missing_docs)] <|fim_suffix|>pub use implementation::DownloadImpl; pub use interface::{DownloadAdapter, MockDownloadAdapter}; pub use scan::GodotMirrorScanner;<|fim_middle|>pub mod download; pub mod error; mod...
code_fim
medium
{ "lang": "rust", "repo": "Srynetix/gdpm", "path": "/crates/gdpm-downloader/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use implementation::DownloadImpl; pub use interface::{DownloadAdapter, MockDownloadAdapter}; pub use scan::GodotMirrorScanner;<|fim_prefix|>// repo: Srynetix/gdpm path: /crates/gdpm-downloader/src/lib.rs //! Downloader crate. #![warn(missing_docs)] <|fim_middle|>pub mod download; pub mod error; mod...
code_fim
medium
{ "lang": "rust", "repo": "Srynetix/gdpm", "path": "/crates/gdpm-downloader/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self(()) } } #[contract_trait] impl Backup for NeverEmigrationExit { unsafe fn backup_unchecked(&self) -> Self { Self(()) } } #[contract_trait] impl<H: Habitat, G: RngCore, R: LineageReference<H>, S: LineageStore<H, R>> EmigrationExit<H, G, R, S> for NeverEmigrationExit {...
code_fim
medium
{ "lang": "rust", "repo": "fossabot/necsim-rust", "path": "/necsim/impls/no-std/src/cogs/emigration_exit/never.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fossabot/necsim-rust path: /necsim/impls/no-std/src/cogs/emigration_exit/never.rs use necsim_core::{ cogs::{Backup, EmigrationExit, Habitat, LineageReference, LineageStore, RngCore}, landscape::{IndexedLocation, Location}, simulation::partial::emigration_exit::PartialSimulation, }; u...
code_fim
medium
{ "lang": "rust", "repo": "fossabot/necsim-rust", "path": "/necsim/impls/no-std/src/cogs/emigration_exit/never.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> // One step to the left assert_eq!(World::adjacent_position(width, width - 1, Left), width - 2); // One step to the left, from (1, 2) assert_eq!(World::adjacent_position(width, 2 * width + 1, Left), 2 * width); // One step up-right, from (0, 1) assert_eq!(World::adjacent_position...
code_fim
hard
{ "lang": "rust", "repo": "aochagavia/FastAnts", "path": "/ant_lib/src/test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // One step up-right, from (0, 1) assert_eq!(World::adjacent_position(width, width, UpRight), 1); // One step up-right, from (0, 2) assert_eq!(World::adjacent_position(width, 2 * width, UpRight), width); // Other possible tests: up-left, down-right, down-left } #[test] fn test_creat...
code_fim
medium
{ "lang": "rust", "repo": "aochagavia/FastAnts", "path": "/ant_lib/src/test.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aochagavia/FastAnts path: /ant_lib/src/test.rs use ant::AntDirection; use simulator::Simulator; use world::World; use test_data::{ant1, default_program, sample0}; #[test] fn test_parse_instructions() { let instrs = ant1(); assert_eq!(instrs.len(), 2333) } #[test] fn test_parse_world() ...
code_fim
hard
{ "lang": "rust", "repo": "aochagavia/FastAnts", "path": "/ant_lib/src/test.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mattsse/nom-sparql path: /src/query/describe.rs use crate::clauses::{solution_modifier, where_clause, SolutionModifier}; use crate::data::{data_set_clause, DataSetClause}; use crate::graph::GroupGraphPattern; use crate::terminals::{sp, sp_enc1}; use crate::var::{var_or_iri, var_or_iris_or_al...
code_fim
hard
{ "lang": "rust", "repo": "mattsse/nom-sparql", "path": "/src/query/describe.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn describe_query(i: &str) -> IResult<&str, DescribeQuery> { map( tuple(( tag_no_case("describe"), sp_enc1(var_or_iris_or_all), terminated(separated_list(sp, data_set_clause), sp), opt(terminated(where_clause, sp)), solutio...
code_fim
hard
{ "lang": "rust", "repo": "mattsse/nom-sparql", "path": "/src/query/describe.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(result) } fn get_geometry_wkt( &self, connection: &Connection, ids: &Vec<i64>, ) -> DatabaseResult<HashMap<i64, Geometry>> { let query = self.format.geometry_query(); let rows = connection.query(query, &[ids])?; let mut object_lines: ...
code_fim
hard
{ "lang": "rust", "repo": "SnakeSolid/rust-show-on-map", "path": "/src/database/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SnakeSolid/rust-show-on-map path: /src/database/client.rs use super::DatabaseError; use super::DatabaseResult; use super::Geometry; use super::NamesGeometry; use super::Point; use crate::config::FormatConfig; use crate::config::FormatType; use postgres::Connection; use postgres::TlsMode; use std...
code_fim
hard
{ "lang": "rust", "repo": "SnakeSolid/rust-show-on-map", "path": "/src/database/client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> formatter.write_str("X25519_dalek public key in bytes") } fn visit_bytes<E>(self, value: &[u8]) -> export::Result<X25519PublicKey, E> where E: de::Error, { let mut fixed_size_data: [u8; X25519PublicKey::LENGTH] = Default::default(); fixed_size_data.copy_fro...
code_fim
hard
{ "lang": "rust", "repo": "xpeerchain/xpeerchain", "path": "/crypto/legacy_crypto/src/x25519.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xpeerchain/xpeerchain path: /crypto/legacy_crypto/src/x25519.rs // Copyright (c) The XPeer Core Contributors // SPDX-License-Identifier: Apache-2.0 //! An implementation of x25519 elliptic curve key pairs required for [Diffie-Hellman key exchange](https://en.wikipedia.org/wiki/Diffie%E2%80%93He...
code_fim
hard
{ "lang": "rust", "repo": "xpeerchain/xpeerchain", "path": "/crypto/legacy_crypto/src/x25519.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Solution::check_record(2), 8); assert_eq!(Solution::check_record(1), 3); assert_eq!(Solution::check_record(10101), 183236316); }<|fim_prefix|>// repo: eranfu/leetcode path: /examples/552_学生出勤记录_II.rs //! [552. 学生出勤记录 II](https://leetcode-cn.com/problems/student-attendance-record-ii...
code_fim
hard
{ "lang": "rust", "repo": "eranfu/leetcode", "path": "/examples/552_学生出勤记录_II.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eranfu/leetcode path: /examples/552_学生出勤记录_II.rs //! [552. 学生出勤记录 II](https://leetcode-cn.com/problems/student-attendance-record-ii/) const MOD: u64 = 1_000_000_007; #[derive(Default)] struct State { l: u64, al: u64, ll: u64, all: u64, p: u64, ap: u64, } impl State { ...
code_fim
hard
{ "lang": "rust", "repo": "eranfu/leetcode", "path": "/examples/552_学生出勤记录_II.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GitNealian/nwallpaper path: /src/app.rs use super::source::Source; use gdk_pixbuf::Pixbuf; use gio::prelude::*; use glib::clone; use glib::{Receiver, Sender}; use gtk::{ApplicationWindow, Builder, Image, prelude::*}; use std::convert::TryInto; use std::thread; use std::time::Duration; use std::{...
code_fim
hard
{ "lang": "rust", "repo": "GitNealian/nwallpaper", "path": "/src/app.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn do_action(&self, action: Action) -> glib::Continue { match action { Action::SwitchOnline => {} Action::SwitchLocal => {} Action::SwitchColor => {} Action::ShowImage(path, name, index) => { let child = self.image_grid.get_child_...
code_fim
hard
{ "lang": "rust", "repo": "GitNealian/nwallpaper", "path": "/src/app.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> application.connect_startup(clone!(@weak application => move |_| { let app = Self::new(&application); Self::init(&app); application.connect_activate(move |_| { app.window.show_now(); app.window.present(); app.sende...
code_fim
hard
{ "lang": "rust", "repo": "GitNealian/nwallpaper", "path": "/src/app.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let bytes = self.as_bytes(); assert!(bytes[bytes.len() - 1] == 0u8); bytes.as_ptr() as CStrPtr } }<|fim_prefix|>// repo: drewet/kiss-ui path: /src/cstr_utils.rs pub type CStrPtr = *const ::libc::c_char; <|fim_middle|>// Why does AsCStr: ?Sized not work?1 pub trait AsCStr { ...
code_fim
medium
{ "lang": "rust", "repo": "drewet/kiss-ui", "path": "/src/cstr_utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drewet/kiss-ui path: /src/cstr_utils.rs pub type CStrPtr = *const ::libc::c_char; <|fim_suffix|>impl AsCStr for &'static str { fn as_cstr(self) -> CStrPtr { let bytes = self.as_bytes(); assert!(bytes[bytes.len() - 1] == 0u8); bytes.as_ptr() as CStrPtr } }<|fim_mi...
code_fim
medium
{ "lang": "rust", "repo": "drewet/kiss-ui", "path": "/src/cstr_utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thoiberg/rust-book-code-snippets path: /threads/src/main.rs use std::thread; use std::time::Duration; // any spawned threads will die if the parent thread ends // spawning a thread returns a JoinHandle, which we can use to keep the parent // thread alive until the spawned thread completes // u...
code_fim
medium
{ "lang": "rust", "repo": "thoiberg/rust-book-code-snippets", "path": "/threads/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> handle.join().unwrap(); for i in 1..5 { println!("hi number {} from the main thread", i); thread::sleep(Duration::from_millis(1)); } }<|fim_prefix|>// repo: thoiberg/rust-book-code-snippets path: /threads/src/main.rs use std::thread; use std::time::Duration; // any spawned t...
code_fim
hard
{ "lang": "rust", "repo": "thoiberg/rust-book-code-snippets", "path": "/threads/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marceloboeira/trpl path: /chapters/chapter-8/example3.rs enum SpreadsheetCell { Int(i32), Float(f64), Text(String), } fn main() { <|fim_suffix|> for r in row { match r { SpreadsheetCell::Int(i) => println!("This is an Int cell, with value: {}", i), ...
code_fim
hard
{ "lang": "rust", "repo": "marceloboeira/trpl", "path": "/chapters/chapter-8/example3.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> where S: Serializer, { let mut s = serializer.serialize_map(self.size)?; for (k, v) in self.iter.clone() { s.serialize_entry(&k, &v)?; } s.end() } }<|fim_prefix|>// repo: dawsongzhao/prusto path: /src/types/util.rs use serde::ser::{Serialize...
code_fim
hard
{ "lang": "rust", "repo": "dawsongzhao/prusto", "path": "/src/types/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dawsongzhao/prusto path: /src/types/util.rs use serde::ser::{SerializeMap, SerializeSeq}; use serde::{Serialize, Serializer}; // serialize iterator // https://github.com/serde-rs/serde/issues/571#issuecomment-252004224 pub struct SerializeIterator<T: Serialize, I: Iterator<Item = T> + Clone> { ...
code_fim
hard
{ "lang": "rust", "repo": "dawsongzhao/prusto", "path": "/src/types/util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<K, V, I> Serialize for SerializePairIterator<K, V, I> where K: Serialize, V: Serialize, I: Iterator<Item = (K, V)> + Clone, { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { let mut s = serializer.serialize_map(self.size)...
code_fim
hard
{ "lang": "rust", "repo": "dawsongzhao/prusto", "path": "/src/types/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// hash with Sha256 pub fn hash(payload:String)-> String{ let mut sha = Sha256::new(); sha.input_str(&payload); let result= sha.result_str(); return result // println!("{:?}", sha.result_str() ); }<|fim_prefix|>// repo: gathuku/rust_cli path: /src/crypto.rs extern crate crypto; use crypto::d...
code_fim
easy
{ "lang": "rust", "repo": "gathuku/rust_cli", "path": "/src/crypto.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gathuku/rust_cli path: /src/crypto.rs extern crate crypto; use crypto::digest::Digest; use crypto::sha2::Sha256; <|fim_suffix|>// hash with Sha256 pub fn hash(payload:String)-> String{ let mut sha = Sha256::new(); sha.input_str(&payload); let result= sha.result_str(); return result ...
code_fim
easy
{ "lang": "rust", "repo": "gathuku/rust_cli", "path": "/src/crypto.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: enclairfarron/actix-web-example path: /src/main.rs use actix_web::{web, App, HttpResponse, middleware, HttpServer, Responder, Result}; use env_logger; mod api; <|fim_suffix|> HttpServer::new(|| { App::new() .wrap(middleware::Logger::default()) .wrap(middlewa...
code_fim
hard
{ "lang": "rust", "repo": "enclairfarron/actix-web-example", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl IntoIterator for DwarfInfoIntoIterator { type Item = DwarfInfo; type IntoIter = std::vec::IntoIter<Self::Item>; fn into_iter(self) -> Self::IntoIter { let file = fs::File::open(&self.elf_path).unwrap(); let mmap = unsafe { memmap::Mmap::map(&file).unwrap() }; let ...
code_fim
hard
{ "lang": "rust", "repo": "forestaa/troll", "path": "/src/library/dwarf.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn get_upper_bound<'abbrev, 'unit>( entry: &gimli::DebuggingInformationEntry< 'abbrev, 'unit, gimli::read::EndianSlice<'abbrev, gimli::RunTimeEndian>, >, ) -> Option<usize> { entry .attr_value(gimli::DW_AT_upper_bound) ...
code_fim
hard
{ "lang": "rust", "repo": "forestaa/troll", "path": "/src/library/dwarf.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forestaa/troll path: /src/library/dwarf.rs tch entries.current() { None => None, Some(entry) => { let offset = Self::get_offset(header, entry); let tag = DwarfTag::from(entry.tag()); let name = Self::get_name(dwarf, entry); ...
code_fim
hard
{ "lang": "rust", "repo": "forestaa/troll", "path": "/src/library/dwarf.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test() { let id = Linear(1, 0); let mut v = BucketVec::new(vec![id; 8], id, |Linear(la, lb), Linear(ra, rb)| { Linear(ra * la, rb + ra * lb) }); for i in 0..8 { let x = 1 + i as i64; v.set(i, Linear(x, x)); } ...
code_fim
hard
{ "lang": "rust", "repo": "vain0x/procon", "path": "/rust/src/procon/buckets.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vain0x/procon path: /rust/src/procon/buckets.rs //! Provides basic bucket structure of square root decomposition. use std; #[derive(Clone, Debug)] pub struct BucketVec<T, F> { node: Vec<T>, bucket: Vec<(usize, usize, T)>, bucket_size: usize, mempty: T, mappend: F, } impl<T...
code_fim
hard
{ "lang": "rust", "repo": "vain0x/procon", "path": "/rust/src/procon/buckets.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fegge/cryptopals-rs path: /src/attacks/statistics.rs use std::string::FromUtf8Error; use crate::crypto::symmetric; #[derive(Debug)] pub enum Error { RecoveryError, DecodingError, } impl std::convert::From<FromUtf8Error> for Error { fn from(_: FromUtf8Error) -> Self { Error...
code_fim
hard
{ "lang": "rust", "repo": "fegge/cryptopals-rs", "path": "/src/attacks/statistics.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn recover_plaintext(ciphertexts: &[Vec<u8>]) -> Result<String, Error> { let result = ciphertexts .iter() .minimize(|ciphertext| score_ciphertext(ciphertext) ); single_byte_xor::recover_plaintext(result.0) } } pub mod repeati...
code_fim
hard
{ "lang": "rust", "repo": "fegge/cryptopals-rs", "path": "/src/attacks/statistics.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DivineStride/Another-Simple-Ray-Tracer path: /src/tests.rs use super::*; use crate::vec3::Vec3; use crate::R; use rayon::prelude::*; use std::f32::consts::PI; <|fim_suffix|> for _ in 0..5 { let color: Vec3 = (0..5) .into_par_iter() .map(|_index| Vec3::new(0.1,...
code_fim
easy
{ "lang": "rust", "repo": "DivineStride/Another-Simple-Ray-Tracer", "path": "/src/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let against = Vec3::new(0.5, 0.5, 0.5); assert_eq!(against.x, color.x); assert_eq!(against.y, color.y); assert_eq!(against.z, color.z); } }<|fim_prefix|>// repo: DivineStride/Another-Simple-Ray-Tracer path: /src/tests.rs use super::*; use crate::vec3::Vec3; use crate::...
code_fim
hard
{ "lang": "rust", "repo": "DivineStride/Another-Simple-Ray-Tracer", "path": "/src/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eyun-tv/webtonic path: /webtonic-server/src/lib.rs //! Server crate of the [`WebTonic`](https://github.com/Sawchord/webtonic) project. //! //! This crate only contains the [`Server`](Server). //! This is necessary, in order to unpack the requests, the client has sent over the websocket connectio...
code_fim
hard
{ "lang": "rust", "repo": "eyun-tv/webtonic", "path": "/webtonic-server/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Turn reply first into protobuf, then into message let reply = webtonic_proto::http_response_to_reply(&mut response).await; let mut msg = BytesMut::new(); match reply.encode(&mut msg) { Ok(()) => (), Err(e) => status_err!(Status::internal(&format!(...
code_fim
hard
{ "lang": "rust", "repo": "eyun-tv/webtonic", "path": "/webtonic-server/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> future::ok( http::Response::builder() .status(200) .header("grpc-status", "12") .header("content-type", "application/grpc") .body(BoxBody::empty()) .unwrap(), ) } } async fn handle_connection2<...
code_fim
hard
{ "lang": "rust", "repo": "eyun-tv/webtonic", "path": "/webtonic-server/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uutils/coreutils path: /fuzz/fuzz_targets/fuzz_test.rs // This file is part of the uutils coreutils package. // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // spell-checker:ignore STRINGSTRING INTEGERINTEGER FILEF...
code_fim
hard
{ "lang": "rust", "repo": "uutils/coreutils", "path": "/fuzz/fuzz_targets/fuzz_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> arg } fuzz_target!(|_data: &[u8]| { let mut rng = rand::thread_rng(); let max_args = rng.gen_range(1..=6); let mut args = vec![OsString::from("test")]; let uumain_exit_status; for _ in 0..max_args { args.push(OsString::from(generate_test_arg())); } // Save the or...
code_fim
hard
{ "lang": "rust", "repo": "uutils/coreutils", "path": "/fuzz/fuzz_targets/fuzz_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wduquette/molt path: /molt/src/tokenizer.rs //! Tokenizer is a type used for parsing a `&str` into slices in a way not easily //! supported by the `Peekable<Chars>` iterator. The basic procedure is as follows: //! //! * Use `next` and `peek` to query the iterator in the usual way. //! * Detect ...
code_fim
hard
{ "lang": "rust", "repo": "wduquette/molt", "path": "/molt/src/tokenizer.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_backslash_subst_hex4() { // \uhhhh: 1-4 hex digits. assert_eq!(bsubst("\\u-"), ('u', Some('-'))); assert_eq!(bsubst("\\u7-"), ('\x07', Some('-'))); assert_eq!(bsubst("\\u77-"), ('w', Some('-'))); assert_eq!(bsubst("\\u077-"), ('w', Some('-'))...
code_fim
hard
{ "lang": "rust", "repo": "wduquette/molt", "path": "/molt/src/tokenizer.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> *data = &mut core::mem::take(data)[n..]; } impl<'a> Future for ReadFuture<'a> { type Output = Result<usize>; fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<usize>> { let this = unsafe { self.get_unchecked_mut() }; loop { if this.output.len...
code_fim
hard
{ "lang": "rust", "repo": "dennisss/dacha", "path": "/pkg/executor/src/linux/file.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dennisss/dacha path: /pkg/executor/src/linux/file.rs use core::future::Future; use core::pin::Pin; use core::task::{Context, Poll}; use std::ffi::CString; use std::sync::Arc; use common::errors::*; use common::io::IoError; use sys::{ c_int, close, open, read, EpollEvents, Errno, IoSlice, Io...
code_fim
hard
{ "lang": "rust", "repo": "dennisss/dacha", "path": "/pkg/executor/src/linux/file.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut rect=Rectangle::new(); let mut window: PistonWindow=WindowSettings::new( "Bouncing-Square", [640,480]) .exit_on_esc(true) .vsync(true) .build() .unwrap(); let mut window_size: (f64, f64)=(0.0,0.0); let mut events = Events::new(Event...
code_fim
hard
{ "lang": "rust", "repo": "NoSuchThingAsRandom/Arcade-Games", "path": "/BouncingSquare/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NoSuchThingAsRandom/Arcade-Games path: /BouncingSquare/src/main.rs extern crate piston; extern crate piston_window; use piston_window::*; use piston::event_loop::{Events, EventLoop, EventSettings}; pub struct Rectangle{ pub colour: [f32; 4], pub position: [f64; 4], velocity:[f64; 2],...
code_fim
hard
{ "lang": "rust", "repo": "NoSuchThingAsRandom/Arcade-Games", "path": "/BouncingSquare/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn content(&self) -> &String { &self.content } }<|fim_prefix|>// repo: kevinwilde/chat_server path: /src/message.rs pub struct Message { from: String, room_id: usize, content: String, } <|fim_middle|>impl Message { pub fn new(from: String, room_id: usize, content: Str...
code_fim
hard
{ "lang": "rust", "repo": "kevinwilde/chat_server", "path": "/src/message.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kevinwilde/chat_server path: /src/message.rs pub struct Message { from: String, room_id: usize, content: String, } <|fim_suffix|> pub fn room_id(&self) -> usize { self.room_id } pub fn content(&self) -> &String { &self.content } }<|fim_middle|>impl Me...
code_fim
hard
{ "lang": "rust", "repo": "kevinwilde/chat_server", "path": "/src/message.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn room_id(&self) -> usize { self.room_id } pub fn content(&self) -> &String { &self.content } }<|fim_prefix|>// repo: kevinwilde/chat_server path: /src/message.rs pub struct Message { from: String, room_id: usize, content: String, } impl Message { pu...
code_fim
medium
{ "lang": "rust", "repo": "kevinwilde/chat_server", "path": "/src/message.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use key::*; pub use sig::*; pub use trace::*;<|fim_prefix|>// repo: VCNinc/trs.js path: /src/lib.rs #![no_std] #[cfg(feature = "std")] #[macro_use] extern crate std; #[cfg(not(feature = "std"))] #[macro_use] extern crate alloc; //-------- Testing stuff --------// <|fim_middle|>#[cfg...
code_fim
medium
{ "lang": "rust", "repo": "VCNinc/trs.js", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VCNinc/trs.js path: /src/lib.rs #![no_std] #[cfg(feature = "std")] #[macro_use] extern crate std; #[cfg(not(feature = "std"))] #[macro_use] extern crate alloc; //-------- Testing stuff --------// #[cfg(test)] mod test_utils; <|fim_suffix|>pub mod key; mod prelude; pub mod s...
code_fim
easy
{ "lang": "rust", "repo": "VCNinc/trs.js", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/uuid/examples/sortable_uuid.rs #[test] #[cfg(feature = "v7")] fn generate_sortable_uuid() { use uuid::Uuid; <|fim_suffix|> assert_eq!(Some(uuid::Version::SortRand), uuid.get_version()); } fn main() {}<|fim_middle|> let uu...
code_fim
easy
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/uuid/examples/sortable_uuid.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Some(uuid::Version::SortRand), uuid.get_version()); } fn main() {}<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/uuid/examples/sortable_uuid.rs #[test] #[cfg(feature = "v7")] fn generate_sortable_uuid() { <|fim_middle|> use uuid::Uuid; let uu...
code_fim
easy
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/uuid/examples/sortable_uuid.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shakadak/Wolf3D path: /Rust/wolf3d/src/main.rs extern crate sdl2; use sdl2::video::{Window, WindowPos, OPENGL}; use sdl2::render::{RenderDriverIndex, ACCELERATED, Renderer}; use sdl2::event::poll_event; use sdl2::event::Event::{Quit, KeyDown}; use sdl2::keycode::KeyCode; use std::num::Float; u...
code_fim
medium
{ "lang": "rust", "repo": "Shakadak/Wolf3D", "path": "/Rust/wolf3d/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut player = player::Player{coordinate: player::Point{x: 3 * 64 + 32, y: 3 * 64 + 32}, direction: 90f64.to_radians(), fov: 70f64.to_radians()}; let plane_center = (width / 2f64, height / 2f64); let d = (width / 2f64) / (player.fov / 2f64).tan(); let map = vec![ vec![1u8, 1, 1,...
code_fim
hard
{ "lang": "rust", "repo": "Shakadak/Wolf3D", "path": "/Rust/wolf3d/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let width = 1366f64; let height = 768f64; sdl2::init(sdl2::INIT_VIDEO); let window = match Window::new("Wolf3D", WindowPos::PosCentered, WindowPos::PosCentered, width as isize, height as isize, OPENGL) { Ok(window) => window, ...
code_fim
medium
{ "lang": "rust", "repo": "Shakadak/Wolf3D", "path": "/Rust/wolf3d/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Error)] pub enum OperationError { #[error("No such device")] ENODEV, #[error("Out of memory")] ENOMEM, #[error("No such file or directory")] ENOENT, #[error("Invalid argument")] EINVAL, #[error("Device or resouce busy")] EBUSY, #[error("Resource ...
code_fim
hard
{ "lang": "rust", "repo": "shun159/vr_types", "path": "/src/vr_messages/error.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shun159/vr_types path: /src/vr_messages/error.rs // Copyright 2020 Eishun Kondoh // SPDX-License-Identifier: Apache-2.0 use thiserror::Error; <|fim_suffix|>#[derive(Debug, Error)] pub enum OperationError { #[error("No such device")] ENODEV, #[error("Out of memory")] ENOMEM, ...
code_fim
hard
{ "lang": "rust", "repo": "shun159/vr_types", "path": "/src/vr_messages/error.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: edawson/pasha path: /rust-pasha/src/decycling.rs /** Pasha: Parallel Algorithms for Approximating Compact Universal Hitting Sets decycling.h Header file for main operations for the decycling set calculation via Mykkeltveit's algorithm. @author Baris Ekim @version 1.0 4/15/19 ...
code_fim
hard
{ "lang": "rust", "repo": "edawson/pasha", "path": "/rust-pasha/src/decycling.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_edge(a: &Vec<isize>, i: usize, k: usize) -> usize { let u = 3.1415926 * 2.0 / (k as f64); let mut q = 0; if i < k {q = k;} else { q = 1; while true { let mut s = 0.0; for l in 1..k+1 { s += a[l] as f64 * (((l - 1 + k - q) %...
code_fim
hard
{ "lang": "rust", "repo": "edawson/pasha", "path": "/rust-pasha/src/decycling.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} pub fn get_edge(a: &Vec<isize>, i: usize, k: usize) -> usize { let u = 3.1415926 * 2.0 / (k as f64); let mut q = 0; if i < k {q = k;} else { q = 1; while true { let mut s = 0.0; for l in 1..k+1 { s += a[l] as f64 * (((l - 1 + k - q...
code_fim
hard
{ "lang": "rust", "repo": "edawson/pasha", "path": "/rust-pasha/src/decycling.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PSeitz/rust-hdbconnect path: /src/protocol/part_attributes.rs use std::fmt; // bit pattern for some attribute parts #[derive(Clone)] pub(crate) struct PartAttributes(u8); impl PartAttributes { pub fn new(bits: u8) -> Self { Self(bits) } // Last part in a sequence of parts (...
code_fim
hard
{ "lang": "rust", "repo": "PSeitz/rust-hdbconnect", "path": "/src/protocol/part_attributes.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// write an ampersand (&) if required fn w_and(b: bool, f: &mut fmt::Formatter) -> Result<bool, fmt::Error> { if b { write!(f, " & ")?; } Ok(true) } #[cfg(test)] mod test { use super::PartAttributes; #[test] fn test_part_attributes() { let no = PartAttributes::new...
code_fim
hard
{ "lang": "rust", "repo": "PSeitz/rust-hdbconnect", "path": "/src/protocol/part_attributes.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/instr_pcmpeqw.rs use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_pcmpeqw.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::PCMPEQW, operand1: Some(Direct(XMM6)), operand2: Some(IndirectScaledDisplaced(RDX, Two, 358350013, Some(OperandSize::Xmmword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None...
code_fim
medium
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_pcmpeqw.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // filename should be &str here pub fn readconfig<'a, T: ?Sized>(filename: &str) -> Result<Box<Outer<'a, T>>, &'static str> where for<'de> T: Deserialize<'de> + 'a { // read the config file let config_data = readfile(filename)...
code_fim
hard
{ "lang": "rust", "repo": "unixunion/rust_generics_yaml_deserializer", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use std::error::Error; // empty holding struct which owns a owned ptr #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Outer<'a, T: 'a + ?Sized> { #[serde(bound(deserialize = "Ptr<'a, T>: Deserialize<'de>"), rename = "data")] pub ptr: Ptr<...
code_fim
hard
{ "lang": "rust", "repo": "unixunion/rust_generics_yaml_deserializer", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: unixunion/rust_generics_yaml_deserializer path: /src/lib.rs #[cfg(test)] mod tests { use crate::generics_yaml_deserializer::{Outer, Ptr}; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; use crate::generics_yaml_deserializer::readfile; ...
code_fim
hard
{ "lang": "rust", "repo": "unixunion/rust_generics_yaml_deserializer", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }