text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>#[test]
fn test_create_table_rejected() {
let sqls: Vec<&str> = vec![
// Lack data-type.
"CREATE TABLE t (c1)",
// Lack data-type again.
"CREATE TABLE t (c1 NOT NULL)",
// Should be parenthesized.
"CREATE TABLE t c1 INTEGER NOT NULL",
// `NOT NUL... | code_fim | hard | {
"lang": "rust",
"repo": "apllodb/apllodb",
"path": "/apllodb-sql-parser/tests/parse_create_table.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apllodb/apllodb path: /apllodb-sql-parser/tests/parse_create_table.rs
use apllodb_sql_parser::{
apllodb_ast::{
ColumnConstraint, ColumnDefinition, Command, CreateTableCommand, DataType, TableConstraint,
TableElement,
},
ApllodbAst, ApllodbSqlParser,
};
use apllodb_te... | code_fim | hard | {
"lang": "rust",
"repo": "apllodb/apllodb",
"path": "/apllodb-sql-parser/tests/parse_create_table.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0xf4lc0n/bme280-visualization path: /src/main.rs
mod gui;
mod sensor;
use gui::display_graph;
use sensor::Sensor;
use std::env::args;
static HELP_MESSAGE: &'static str = "Visualization of BME280 sensor measurements\n\n\
USAGE:\n\
... | code_fim | hard | {
"lang": "rust",
"repo": "0xf4lc0n/bme280-visualization",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (raw_data, h1) = Sensor::start_receiving_data(bme280);
let (parsed_data, h2) = Sensor::parse_data(raw_data);
display_graph(parsed_data);
match h1.join().unwrap() {
Err(e) if !e.description.contains("closed channel") => eprintln!("Serial reader: {}", e),
_ => (),
}
... | code_fim | hard | {
"lang": "rust",
"repo": "0xf4lc0n/bme280-visualization",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: crsaracco/druid path: /druid-shell/src/platform/x11/application.rs
// Copyright 2020 The xi-editor Authors.
//
// 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
//
// ... | code_fim | hard | {
"lang": "rust",
"repo": "crsaracco/druid",
"path": "/druid-shell/src/platform/x11/application.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct Application;
impl Application {
pub fn new(_handler: Option<Box<dyn AppHandler>>) -> Application {
Application
}
pub(crate) fn add_xwindow(id: u32, xwindow: XWindow) {
WINDOW_MAP.with(|map| map.borrow_mut().insert(id, xwindow));
}
pub(crate) fn get_connect... | code_fim | hard | {
"lang": "rust",
"repo": "crsaracco/druid",
"path": "/druid-shell/src/platform/x11/application.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fooki/Kalle-Entertainment-System path: /tetris/src/button_group.rs
pub struct ButtonGroup<'a> {
labels: &'a [&'a str],
index: usize
}
impl<'a> ButtonGroup<'a> {
pub fn new(labels: &'a [&str]) -> Self {
Self { labels, index: 0 }
}
pub fn current(&self) -> &'a str {
... | code_fim | medium | {
"lang": "rust",
"repo": "fooki/Kalle-Entertainment-System",
"path": "/tetris/src/button_group.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut group = ButtonGroup::new(&["Play", "Options", "Quit"]);
assert_eq!(group.current(), "Play");
group.down();
assert_eq!(group.current(), "Options");
group.down();
assert_eq!(group.current(), "Quit");
group.down();
assert_eq!(group.cu... | code_fim | hard | {
"lang": "rust",
"repo": "fooki/Kalle-Entertainment-System",
"path": "/tetris/src/button_group.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gissleh/aoc2019 path: /src/day04.rs
use common::aoc::{load_input, run_many, print_time, print_result};
fn main() {
let input = load_input("day04");
let ((start, end), dur_parse) = run_many(10000, || parse_input(&input));
let (res_part1_bf, dur_part1_bf) = run_many(100, || part1_bf(... | code_fim | hard | {
"lang": "rust",
"repo": "gissleh/aoc2019",
"path": "/src/day04.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return (false, skip);
} else if curr_digit == prev_digit {
if prev_double && curr_digit == has_double {
bad_double = curr_digit;
} else if has_double == 10 || has_double == bad_double {
has_double = curr_digit;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "gissleh/aoc2019",
"path": "/src/day04.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zevstravitz/Poker path: /rust/src/tests.rs
use crate::card_utils::*;
#[test]
fn uint_hands() {
let hand: u64 = str2hand("Ac2d7h9cTd2s8c");
assert_eq!(suit(card(hand, 0)), CLUBS);
assert_eq!(rank(card(hand, 0)), 14);
assert_eq!(suit(card(hand, 1)), DIAMONDS);
assert_eq!(rank(... | code_fim | hard | {
"lang": "rust",
"repo": "zevstravitz/Poker",
"path": "/rust/src/tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Test different hand type comparisons
assert!(royal_flush > straight_flush);
assert!(royal_flush > trips);
assert!(straight_flush > full_house);
assert!(trips > two_pair);
assert!(high_card < pair);
assert!(straight < flush);
// Test rank levels within hands
assert!(... | code_fim | hard | {
"lang": "rust",
"repo": "zevstravitz/Poker",
"path": "/rust/src/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nathankleyn/advent-of-code-2017 path: /rust/day-3/src/lib.rs
use std::collections::HashMap;
#[allow(dead_code)]
fn day_3_part_1(index: i64) -> i64 {
if index == 1 {
return 0;
}
let layer = (((index as f64).sqrt() - 1.0) / 2.0).ceil() as i64;
let distance_to_closest_corn... | code_fim | hard | {
"lang": "rust",
"repo": "nathankleyn/advent-of-code-2017",
"path": "/rust/day-3/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> vec![
Coords { x: self.x - 1, y: self.y - 1 },
Coords { x: self.x, y: self.y - 1 },
Coords { x: self.x + 1, y: self.y - 1 },
Coords { x: self.x - 1, y: self.y },
Coords { x: self.x + 1, y: self.y },
Coords { x: self.x - 1, y: ... | code_fim | hard | {
"lang": "rust",
"repo": "nathankleyn/advent-of-code-2017",
"path": "/rust/day-3/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> gl.draw(args.viewport(), |c, gl| {
graphics::clear(WHITE, gl);
let tr = c.transform.scale(BLOCK_SIZE as f64, BLOCK_SIZE as f64);
for y in 0 .. GRID_HEIGHT as i32 {
for x in 0 .. GRID_WIDTH as i32 {
if grid.test(x, y) {
let coords = [x as f64, ... | code_fim | hard | {
"lang": "rust",
"repo": "jorendorff/branches",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> const N: i32 = 100;
for i in 0 .. N {
let t = i as f64 / N as f64;
let a = 3.0 * pi * t;
let x = cx + t * r * a.cos();
let y = cy + t * r * a.sin();
grid.set(x as i32, y as i32);
}
grid
}
fn main() {
// Change this to OpenGL::V2_1 if not workin... | code_fim | hard | {
"lang": "rust",
"repo": "jorendorff/branches",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jorendorff/branches path: /src/main.rs
//! This program draws a growing, branching shape. The effect is something like
//! a colony of bacteria or the veins of a leaf.
//!
//! The algorithm is called DLA (diffusion limited aggregation) and it works
//! like this:
//!
//! * Start with a single ... | code_fim | hard | {
"lang": "rust",
"repo": "jorendorff/branches",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Queryable, Identifiable, AsChangeset, Debug)]
#[primary_key(id)]
pub struct Guild {
pub id: i64,
pub admin_roles: Vec<i64>,
pub audit: bool,
pub audit_channel: i64,
pub autorole: bool,
pub autoroles: Vec<i64>,
pub ignored_channels: Vec<i64>,
pub introduction: bool,... | code_fim | medium | {
"lang": "rust",
"repo": "the-sporkening/Sporkbot-Rust",
"path": "/src/db/models.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: the-sporkening/Sporkbot-Rust path: /src/db/models.rs
use chrono::{DateTime, TimeZone, Utc};
use serenity::model::id::{UserId, RoleId};
use std::fmt::{Display, Formatter, Result as FmtResult};
use super::schema::*;
// QUERYABLES
<|fim_suffix|>#[derive(Queryable, Identifiable, AsChangeset, Debug... | code_fim | hard | {
"lang": "rust",
"repo": "the-sporkening/Sporkbot-Rust",
"path": "/src/db/models.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Queryable, Identifiable, AsChangeset, Debug)]
#[primary_key(id, guild_id)]
pub struct User<Tz: TimeZone> {
pub id: i64,
pub guild_id: i64,
pub user_id: i64,
pub xp: i64,
pub last_message: DateTime<Tz>,
}<|fim_prefix|>// repo: the-sporkening/Sporkbot-Rust path: /src/db/models.... | code_fim | hard | {
"lang": "rust",
"repo": "the-sporkening/Sporkbot-Rust",
"path": "/src/db/models.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m-kann0/atcoder-rust path: /examples/lib_lis.rs
/// 最長増加部分列(LIS:Longest Increasing Subsequence)の長さを求める。
/// 蟻本p65
fn main() {
let a = vec![4, 2, 3, 1, 5];
println!("{}", lis::lis(&a, std::usize::MAX));
}
<|fim_suffix|> let mut ans = 0;
for i in 0..v.len() {
if... | code_fim | hard | {
"lang": "rust",
"repo": "m-kann0/atcoder-rust",
"path": "/examples/lib_lis.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ans = 0;
for i in 0..v.len() {
if dp[i] < inf {
ans = i + 1;
}
}
ans
}
}<|fim_prefix|>// repo: m-kann0/atcoder-rust path: /examples/lib_lis.rs
/// 最長増加部分列(LIS:Longest Increasing Subsequence)の長さを求める。
/// 蟻本p65
fn main() {
... | code_fim | hard | {
"lang": "rust",
"repo": "m-kann0/atcoder-rust",
"path": "/examples/lib_lis.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let game_data = GameDataBuilder::default()
.with_system_desc(PrefabLoaderSystemDesc::<TileMapPrefab>::default(), "", &[])
.with_bundle(TransformBundle::new())?
.with_bundle(
InputBundle::<StringBindings>::new()
.with_bindings_from_file("examples/conc... | code_fim | hard | {
"lang": "rust",
"repo": "jmeggitt/amethyst-tiled",
"path": "/examples/concept/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _map_entity = world
.create_entity()
.with(prefab_handle)
.with(Transform::default())
.build();
}
}
fn main() -> amethyst::Result<()> {
amethyst::Logger::from_config(Default::default())
.level_for("amethyst_tiles", log::LevelFilt... | code_fim | hard | {
"lang": "rust",
"repo": "jmeggitt/amethyst-tiled",
"path": "/examples/concept/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jmeggitt/amethyst-tiled path: /examples/concept/main.rs
use amethyst::{
assets::{PrefabLoader, PrefabLoaderSystemDesc},
core::{math::Vector3, Transform, TransformBundle},
ecs::{Entities, Join, Read, ReadStorage, System, WriteStorage},
input::{InputBundle, InputHandler, StringBind... | code_fim | hard | {
"lang": "rust",
"repo": "jmeggitt/amethyst-tiled",
"path": "/examples/concept/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>sboard_square;
//
mod _1816_truncate_sentence;<|fim_prefix|>// repo: te-ori/rustgym path: /leetcode/src/d18/mod.rs
//
mod _1800_maximum_ascending_subarray_sum;
/<|fim_middle|>/
mod _1805_number_of_different_integers_in_a_string;
//
mod _1812_determine_color_of_a_ches | code_fim | medium | {
"lang": "rust",
"repo": "te-ori/rustgym",
"path": "/leetcode/src/d18/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: te-ori/rustgym path: /leetcode/src/d18/mod.rs
//
mod _1800_maximum_ascending_subarray_sum;
/<|fim_suffix|>sboard_square;
//
mod _1816_truncate_sentence;<|fim_middle|>/
mod _1805_number_of_different_integers_in_a_string;
//
mod _1812_determine_color_of_a_ches | code_fim | medium | {
"lang": "rust",
"repo": "te-ori/rustgym",
"path": "/leetcode/src/d18/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RSWilli/advent-of-code path: /2022/rust/lib/src/spatial/point2d.rs
use std::{
fmt::{Debug, Display, Formatter},
ops::{Add, Sub},
};
use super::position::Position;
#[derive(PartialEq, Eq, Hash, Clone, Copy)]
pub struct Point2D {
pub x: isize,
pub y: isize,
}
impl Point2D {
... | code_fim | hard | {
"lang": "rust",
"repo": "RSWilli/advent-of-code",
"path": "/2022/rust/lib/src/spatial/point2d.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn distance(&self, other: &Self) -> usize {
let dx = (self.x - other.x).unsigned_abs();
let dy = (self.y - other.y).unsigned_abs();
dx + dy
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_to_index() {
let min = Point2D { x: 0, y: 0 };
... | code_fim | hard | {
"lang": "rust",
"repo": "RSWilli/advent-of-code",
"path": "/2022/rust/lib/src/spatial/point2d.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hiroaki-yamamoto/midas path: /backend/libs/exchanges/history/src/entities/klines.rs
use ::std::convert::TryFrom;
use ::errors::UnknownExchangeError;
use ::rpc::entities::Exchanges;
<|fim_suffix|> return match value {
KlinesByExchange::Binance(klines) => Ok(klines),
};
}
}
impl ... | code_fim | hard | {
"lang": "rust",
"repo": "hiroaki-yamamoto/midas",
"path": "/backend/libs/exchanges/history/src/entities/klines.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return match value {
KlinesByExchange::Binance(klines) => Ok(klines),
};
}
}
impl KlinesByExchange {
pub fn exchange(&self) -> Exchanges {
return match self {
&Self::Binance(_) => Exchanges::Binance,
};
}
}<|fim_prefix|>// repo: hiroaki-yamamoto/midas path: /backend/lib... | code_fim | hard | {
"lang": "rust",
"repo": "hiroaki-yamamoto/midas",
"path": "/backend/libs/exchanges/history/src/entities/klines.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// #[test]
// #[should_panic(expected = "Threshold K can not be larger than N")]
// fn test_generate_invalid_k() {
// let share1 = "2-1-1YAYwmOHqZ69jA".to_string().into_bytes();
//
// generate_shares(10, 5, share1.as_slice(), true).unwrap();
// }<|fim_prefix|>// repo: elcritch/RustySecrets path: ... | code_fim | medium | {
"lang": "rust",
"repo": "elcritch/RustySecrets",
"path": "/tests/json_share_tests.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: elcritch/RustySecrets path: /tests/json_share_tests.rs
extern crate rusty_secrets;
use rusty_secrets::sss::generate_shares_format;
use rusty_secrets::sss::share_from_string;
use rusty_secrets::sss::recover_secret_format;
use rusty_secrets::sss::ShareFormatKind;
#[test]
fn test_generate_basic_s... | code_fim | medium | {
"lang": "rust",
"repo": "elcritch/RustySecrets",
"path": "/tests/json_share_tests.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jihoonson/tokamak path: /src/memory/lib.rs
#![feature(oom)]
#![feature(heap_api)]
#![feature(alloc)]
extern crate alloc;
extern crate bytesize;
#[macro_use]
extern crate log;
<|fim_suffix|>pub use self::arena::Arena;
mod arena;<|fim_middle|>pub use self::buffer::{Buf, UnSafeDatumWriter, UnSafeD... | code_fim | medium | {
"lang": "rust",
"repo": "jihoonson/tokamak",
"path": "/src/memory/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use self::arena::Arena;
mod arena;<|fim_prefix|>// repo: jihoonson/tokamak path: /src/memory/lib.rs
#![feature(oom)]
#![feature(heap_api)]
#![feature(alloc)]
extern crate alloc;
extern crate bytesize;
#[macro_use]
extern crate log;
<|fim_middle|>pub use self::buffer::{Buf, UnSafeDatumWriter, UnSafeD... | code_fim | medium | {
"lang": "rust",
"repo": "jihoonson/tokamak",
"path": "/src/memory/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>e_braced_list;
// " and ' quote types
pub mod quotes;<|fim_prefix|>// repo: adam-cyclones/lib-jess path: /src/jess_utils/matches/mod.rs
// index for matchers and captures
#![allow(dead_code<|fim_middle|>)]
// valid names
pub mod common_name;
// @rules
pub mod css_directive;
// { foo, bar1, _baz }
pub mod... | code_fim | medium | {
"lang": "rust",
"repo": "adam-cyclones/lib-jess",
"path": "/src/jess_utils/matches/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adam-cyclones/lib-jess path: /src/jess_utils/matches/mod.rs
// index for matchers and captures
#![allow(dead_code<|fim_suffix|>mod css_directive;
// { foo, bar1, _baz }
pub mod name_braced_list;
// " and ' quote types
pub mod quotes;<|fim_middle|>)]
// valid names
pub mod common_name;
// @rules
... | code_fim | easy | {
"lang": "rust",
"repo": "adam-cyclones/lib-jess",
"path": "/src/jess_utils/matches/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let b: Borrowed = Default::default();
println!("b is {:?}", b);
}<|fim_prefix|>// repo: youngqqcn/RustNotes path: /rust-by-example/15-作用域规则/14-trait生命周期.rs
// Author: yqq
// Date: 2022-11-13 16:10:02
// Description: trait 生命周期
#[derive(Debug)]
struct Borrowed<'a> {
x: &'a i32
}
impl <'a>D... | code_fim | medium | {
"lang": "rust",
"repo": "youngqqcn/RustNotes",
"path": "/rust-by-example/15-作用域规则/14-trait生命周期.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: youngqqcn/RustNotes path: /rust-by-example/15-作用域规则/14-trait生命周期.rs
// Author: yqq
// Date: 2022-11-13 16:10:02
// Description: trait 生命周期
<|fim_suffix|> let b: Borrowed = Default::default();
println!("b is {:?}", b);
}<|fim_middle|>
#[derive(Debug)]
struct Borrowed<'a> {
x: &'a i32... | code_fim | medium | {
"lang": "rust",
"repo": "youngqqcn/RustNotes",
"path": "/rust-by-example/15-作用域规则/14-trait生命周期.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
x: &10
}
}
}
fn main() {
let b: Borrowed = Default::default();
println!("b is {:?}", b);
}<|fim_prefix|>// repo: youngqqcn/RustNotes path: /rust-by-example/15-作用域规则/14-trait生命周期.rs
// Author: yqq
// Date: 2022-11-13 16:10:02
// Description: trait 生命周期
<... | code_fim | medium | {
"lang": "rust",
"repo": "youngqqcn/RustNotes",
"path": "/rust-by-example/15-作用域规则/14-trait生命周期.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // lookup sorted set computation
pub fn tbllkp_sortedset(&self, witness: &[Vec<F>; COLUMNS]) -> LookupEvals<F> {
let n = self.cs.domain.d1.size as usize;
// get lookup values
let lw = witness[COLUMNS - 1]
.iter()
.take(n - 1)
.zip(self.cs... | code_fim | hard | {
"lang": "rust",
"repo": "Federico2014/proof-systems",
"path": "/circuits/plonk-15-wires/src/polynomials/tbllkp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Federico2014/proof-systems path: /circuits/plonk-15-wires/src/polynomials/tbllkp.rs
/*****************************************************************************************************************
This source file implements table loopup polynomials.
*****************************************... | code_fim | hard | {
"lang": "rust",
"repo": "Federico2014/proof-systems",
"path": "/circuits/plonk-15-wires/src/polynomials/tbllkp.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LPGhatguy/take5 path: /src/parsers/take_while.rs
#[inline(always)]
pub fn take_while<'source, T>(condition: T) -> impl Fn(&'source str) -> Option<(&'source str, &'source str)>
where T: Fn(char) -> bool {
move |source: &'source str| {
let mut start_pos = 0;
for (pos, char) in source.char_i... | code_fim | medium | {
"lang": "rust",
"repo": "LPGhatguy/take5",
"path": "/src/parsers/take_while.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let skip_whitespace = take_while(is_whitespace);
let result = skip_whitespace("ayy");
assert!(result.is_some());
let (value, rest) = result.unwrap();
assert_eq!(value, "");
assert_eq!(rest, "ayy");
}<|fim_prefix|>// repo: LPGhatguy/take5 path: /src/parsers/take_while.rs
#[inline(always)]
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "LPGhatguy/take5",
"path": "/src/parsers/take_while.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> c == ' ' || c == '\n' || c == '\r' || c == '\t'
}
let skip_whitespace = take_while(is_whitespace);
let result = skip_whitespace("ayy");
assert!(result.is_some());
let (value, rest) = result.unwrap();
assert_eq!(value, "");
assert_eq!(rest, "ayy");
}<|fim_prefix|>// repo: LPGhatguy/take5 pat... | code_fim | medium | {
"lang": "rust",
"repo": "LPGhatguy/take5",
"path": "/src/parsers/take_while.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gadomski/pos-rs path: /src/poq.rs
//! Position and orientation quality files.
use byteorder::{LittleEndian, ReadBytesExt};
use failure::Error;
use point::{Accuracy, SatelliteCount};
use std::fs::File;
use std::io::{BufReader, Read, Seek};
use std::iter::IntoIterator;
use std::path::Path;
use un... | code_fim | hard | {
"lang": "rust",
"repo": "gadomski/pos-rs",
"path": "/src/poq.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// poq file version.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Version {
major: u16,
minor: u16,
}
impl Version {
/// Creates a new version.
///
/// # Examples
///
/// ```
/// use pos::poq::Version;
/// Version::new(1, 1);
/// ```
pub fn new(major: u... | code_fim | hard | {
"lang": "rust",
"repo": "gadomski/pos-rs",
"path": "/src/poq.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.reader.read_accuracy().unwrap()
}
}
/// poq file version.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Version {
major: u16,
minor: u16,
}
impl Version {
/// Creates a new version.
///
/// # Examples
///
/// ```
/// use pos::poq::Version;
/// V... | code_fim | hard | {
"lang": "rust",
"repo": "gadomski/pos-rs",
"path": "/src/poq.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thoov/volta path: /crates/volta-core/src/command.rs
use std::ffi::OsStr;
use std::process::Command;
use cfg_if::cfg_if;
cfg_if! {
if #[cfg(windows)] {
pub fn create_command<E>(exe: E) -> Command
where
E: AsRef<OsStr>
{
// Several of the node ... | code_fim | hard | {
"lang": "rust",
"repo": "thoov/volta",
"path": "/crates/volta-core/src/command.rs",
"mode": "psm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_suffix|> command.arg(exe);
command
}
} else {
pub fn create_command<E>(exe: E) -> Command
where
E: AsRef<OsStr>
{
Command::new(exe)
}
}
}<|fim_prefix|>// repo: thoov/volta path: /crates/volta-core/src/command.rs
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "thoov/volta",
"path": "/crates/volta-core/src/command.rs",
"mode": "spm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Instead of: <COMMAND> <ARGUMENTS>
// See: https://github.com/rust-lang/rust/issues/42791 For a longer discussion
let mut command = Command::new("cmd.exe");
command.arg("/C");
command.arg(exe);
command
}
} else {
pub fn c... | code_fim | hard | {
"lang": "rust",
"repo": "thoov/volta",
"path": "/crates/volta-core/src/command.rs",
"mode": "spm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KeenS/dynein path: /src/bootstrap.rs
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* 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
*
*... | code_fim | hard | {
"lang": "rust",
"repo": "KeenS/dynein",
"path": "/src/bootstrap.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut zarchive = zip::ZipArchive::new(File::open(fpath)?)?;
debug!("Opened the zip archive File just written: {:?}", zarchive);
for i in 0..zarchive.len() {
let mut f: zip::read::ZipFile = zarchive.by_index(i)?;
debug!("target ZipFile name: {}", f.name());
let unzipp... | code_fim | hard | {
"lang": "rust",
"repo": "KeenS/dynein",
"path": "/src/bootstrap.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kdy1/swc path: /crates/swc_ecma_transforms_typescript/src/import_export_assign.rs
use swc_common::{errors::HANDLER, Mark, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_utils::{member_expr, private_ident, quote_ident, quote_str, ExprFactory};
use swc_ecma_visit::{
as_folder, noop_visit_mut_typ... | code_fim | hard | {
"lang": "rust",
"repo": "kdy1/swc",
"path": "/crates/swc_ecma_transforms_typescript/src/import_export_assign.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for item in n.drain(..) {
match item {
ModuleItem::ModuleDecl(ModuleDecl::TsImportEquals(v))
if matches!(
&*v,
TsImportEqualsDecl {
is_type_only: false,
... | code_fim | hard | {
"lang": "rust",
"repo": "kdy1/swc",
"path": "/crates/swc_ecma_transforms_typescript/src/import_export_assign.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pisa-engine/pisa-jr path: /src/index.rs
use libflate::gzip::Decoder;
use std::fs::File;
use std::io::{BufReader, Read};
use std::path::PathBuf;
use structopt::StructOpt;
use trec_text::Parser;
#[derive(StructOpt, Debug)]
struct Opt {
#[structopt(help = "Collection files in TREC format")]
... | code_fim | medium | {
"lang": "rust",
"repo": "pisa-engine/pisa-jr",
"path": "/src/index.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let empty: Box<dyn Read> = Box::new(std::io::empty());
let args = Opt::from_args();
let input = args
.input
.into_iter()
.map(|path| File::open(path).map(BufReader::new))
.fold(empty, |acc, f| match f {
Ok(f) => Box::new(acc.chain(f)),
Er... | code_fim | medium | {
"lang": "rust",
"repo": "pisa-engine/pisa-jr",
"path": "/src/index.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (limit_entry, count_entry) in limit_header.split(',').zip(count_header.split(',')) {
let (limit, limit_secs) = scan_fmt!(limit_entry, "{d}:{d}", usize, u64)
.unwrap_or_else(|_| panic!("Failed to parse limit entry \"{}\".", limit_entry));
let (count, count_secs) = scan_f... | code_fim | hard | {
"lang": "rust",
"repo": "MingweiSamuel/Riven",
"path": "/riven/src/req/rate_limit.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MingweiSamuel/Riven path: /riven/src/req/rate_limit.rs
use std::cmp;
use std::time::{Duration, Instant};
#[cfg(feature = "tracing")]
use tracing as log;
use parking_lot::{RwLock, RwLockUpgradableReadGuard};
use reqwest::{Response, StatusCode};
use scan_fmt::scan_fmt;
use tokio::sync::Notify;
... | code_fim | hard | {
"lang": "rust",
"repo": "MingweiSamuel/Riven",
"path": "/riven/src/req/rate_limit.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if buckets.len() != limit_header.split(',').count() {
return true;
}
for (limit_header_entry, bucket) in limit_header.split(',').zip(buckets) {
// limit_header_entry "100:60" means 100 req per 60 sec.
let bucket_entry = format!(
"{}:{}",
bucket.g... | code_fim | hard | {
"lang": "rust",
"repo": "MingweiSamuel/Riven",
"path": "/riven/src/req/rate_limit.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut position = 0;
histogram.iter().enumerate().for_each(|(value, count)| {
if *count > 0 {
let quotient = *count / 4;
let remainder = count % 4;
let v = dummy.to_generic(value);
for _ in 0..quotient {
unsafe {
... | code_fim | hard | {
"lang": "rust",
"repo": "lakwet/voracious_sort",
"path": "/src/sorts/counting_sort.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let dummy = arr[0];
let mut position = 0;
histogram.iter().enumerate().for_each(|(value, count)| {
if *count > 0 {
let quotient = *count / 4;
let remainder = count % 4;
let v = dummy.to_generic(value);
for _ in 0..quotient {
... | code_fim | hard | {
"lang": "rust",
"repo": "lakwet/voracious_sort",
"path": "/src/sorts/counting_sort.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lakwet/voracious_sort path: /src/sorts/counting_sort.rs
use super::super::{RadixKey, Radixable};
use super::utils::Params;
fn counting_sort_aux<T, K>(arr: &mut [T], p: Params)
where
T: Radixable<K>,
K: RadixKey,
{
let dummy = arr[0];
let mut histogram = vec![0; p.radix_range];
... | code_fim | hard | {
"lang": "rust",
"repo": "lakwet/voracious_sort",
"path": "/src/sorts/counting_sort.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tonylpt/WhosInBot-Rust path: /src/models/roll_calls/status.rs
use diesel::backend::Backend;
use diesel::deserialize::{self, FromSql};
use diesel::serialize::{self, Output, ToSql};
use diesel::sql_types::Text;
use std::fmt;
use std::io::Write;
use std::str::FromStr;
/** Boilerplate to enable enu... | code_fim | hard | {
"lang": "rust",
"repo": "tonylpt/WhosInBot-Rust",
"path": "/src/models/roll_calls/status.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_status_from_valid_string() -> Result<(), String> {
assert_eq!(CallStatus::Open, "OPEN".parse::<CallStatus>()?);
assert_eq!(CallStatus::Closed, "CLOSED".parse::<CallStatus>()?);
Ok(())
}
#[test]
fn test_status_from_invalid_string() {
asse... | code_fim | hard | {
"lang": "rust",
"repo": "tonylpt/WhosInBot-Rust",
"path": "/src/models/roll_calls/status.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match val {
raw::InvitationStatus::Pending => Self::Pending,
raw::InvitationStatus::Accepted => Self::Accepted,
}
}
}
impl From<Option<raw::InvitationAffinity>> for InvitationAffinity {
#[inline]
fn from(val: Option<raw::InvitationAffinity>) -> Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "mirryi/hangouts-rs",
"path": "/src/raw/convert.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mirryi/hangouts-rs path: /src/raw/convert.rs
use crate::{
raw, Address, AttachmentSegment, ChatMessage, ChatSegment, Conversation, ConversationRename,
ConversationStatus, EmbedItem, Event, EventData, Formatting, Geo, HangoutEvent,
HangoutEventType, Hangouts, InvitationAffinity, Invit... | code_fim | hard | {
"lang": "rust",
"repo": "mirryi/hangouts-rs",
"path": "/src/raw/convert.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[rstest]
#[case(OrganizationEntityType::CivilLawPartnership, "CIVIL_LAW_PARTNERSHIP")]
#[case(OrganizationEntityType::EntrepreneurialCompany, "ENTREPRENEURIAL_COMPANY")]
#[case(OrganizationEntityType::GlobalPartnership, "GLOBAL_PARTNERSHIP")]
#[case(OrganizationEnt... | code_fim | hard | {
"lang": "rust",
"repo": "CarloMicieli/trenako",
"path": "/crates/common/src/organizations.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CarloMicieli/trenako path: /crates/common/src/organizations.rs
//! the module includes everything related to organizations
use serde_derive::{Deserialize, Serialize};
use sqlx::Type;
use strum_macros;
use strum_macros::{Display, EnumString};
/// The many types of business entities defined in t... | code_fim | hard | {
"lang": "rust",
"repo": "CarloMicieli/trenako",
"path": "/crates/common/src/organizations.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[case] input: &str,
#[case] expected: Result<OrganizationEntityType, ParseError>,
) {
let org_type = input.parse::<OrganizationEntityType>();
assert_eq!(expected, org_type);
}
#[rstest]
#[case(OrganizationEntityType::CivilLa... | code_fim | hard | {
"lang": "rust",
"repo": "CarloMicieli/trenako",
"path": "/crates/common/src/organizations.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YesSeri/rust-book path: /src/chap9/tweet.rs
use super::summary::Summary;
#[derive(Debug)]
pub struct Tweet {
pub username: String,
pub content: String,
pub reply: bool,
p<|fim_suffix|> String {
format!("{}: {}", self.username, self.content)
}
}<|fim_middle|>ub retweet... | code_fim | medium | {
"lang": "rust",
"repo": "YesSeri/rust-book",
"path": "/src/chap9/tweet.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> String {
format!("{}: {}", self.username, self.content)
}
}<|fim_prefix|>// repo: YesSeri/rust-book path: /src/chap9/tweet.rs
use super::summary::Summary;
#[derive(Debug)]
pub struct Tweet {
pub username: String,
pub content: String,
pub reply: bool,
p<|fim_middle|>ub retweet... | code_fim | medium | {
"lang": "rust",
"repo": "YesSeri/rust-book",
"path": "/src/chap9/tweet.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aws-cloudformation/cloudformation-guard path: /guard/src/rules/libyaml/event.rs
use crate::rules::libyaml::{cstr, cstr::CStr, tag::Tag};
use std::{borrow::Cow, fmt, fmt::Debug, ptr::NonNull, slice};
#[allow(clippy::unsafe_removed_from_name)]
use unsafe_libyaml as sys;
#[derive(Debug)]
pub(crate... | code_fim | hard | {
"lang": "rust",
"repo": "aws-cloudformation/cloudformation-guard",
"path": "/guard/src/rules/libyaml/event.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'input> Debug for Scalar<'input> {
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
let Scalar {
anchor,
tag,
value,
style,
repr: _,
} = self;
struct LossySlice<'a>(&'a [u8]);
impl<'a> Debu... | code_fim | hard | {
"lang": "rust",
"repo": "aws-cloudformation/cloudformation-guard",
"path": "/guard/src/rules/libyaml/event.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jimliang/rust_codewars path: /src/race.rs
// https://www.codewars.com/kata/55e2adece53b4cdcb900006c/train/rust
<|fim_suffix|> if v1 >= v2 {
return None;
}
let s = g * 3600 / (v2 - v1);
let hour = s / 3600;
let min = s / 60 % 60;
let sec = s % 60;
Some(vec![ho... | code_fim | medium | {
"lang": "rust",
"repo": "jimliang/rust_codewars",
"path": "/src/race.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn basic_tests() {
assert_eq!(race(720, 850, 70), Some(vec![0, 32, 18]));
assert_eq!(race(80, 100, 40), Some(vec![2, 0, 0]));
assert_eq!(race(80, 91, 37), Some(vec![3, 21, 49]));
assert_eq!(race(820, 850, 550), Some(vec![18, 20, 0]));
assert_eq!(race(820, 81, 550), None);
}<|fi... | code_fim | medium | {
"lang": "rust",
"repo": "jimliang/rust_codewars",
"path": "/src/race.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: deathlyfrantic/vimlfmt path: /parser/src/lib.rs
use crate::parser::Result;
pub use crate::{
modifier::Modifier,
node::{BinaryOpKind, Node, UnaryOpKind},
};
use lazy_static::lazy_static;
use regex::Regex;
mod command;
mod exarg;
mod modifier;
mod node;
mod parser;
mod reader;
mod token;
... | code_fim | hard | {
"lang": "rust",
"repo": "deathlyfrantic/vimlfmt",
"path": "/parser/src/lib.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn is_word1(&self) -> bool {
self.is_ascii_alphabetic() || *self == '_'
}
fn is_white(&self) -> bool {
*self == ' ' || *self == '\t'
}
fn is_name(&self) -> bool {
self.is_ascii_alphanumeric() || ['_', ':', '#'].contains(&self)
}
}
fn isargname(s: &str) ->... | code_fim | hard | {
"lang": "rust",
"repo": "deathlyfrantic/vimlfmt",
"path": "/parser/src/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doytsujin/winrt-rs path: /crates/libs/windows/src/Windows/Embedded/DeviceLockdown/mod.rs
#[doc(hidden)]
#[repr(transparent)]
pub struct IDeviceLockdownProfileInformation(::windows::core::IUnknown);
unsafe impl ::windows::core::Vtable for IDeviceLockdownProfileInformation {
type Vtable = IDev... | code_fim | hard | {
"lang": "rust",
"repo": "doytsujin/winrt-rs",
"path": "/crates/libs/windows/src/Windows/Embedded/DeviceLockdown/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BloodHaawk/r-shmup_1 path: /src/components/player.rs
use amethyst::{
assets::{PrefabData, ProgressCounter},
derive::PrefabData,
ecs::{Component, DenseVecStorage, Entity, WriteStorage},
renderer::sprite::prefab::SpriteScenePrefab,
Error,
};
use serde::{Deserialize, Serialize}... | code_fim | medium | {
"lang": "rust",
"repo": "BloodHaawk/r-shmup_1",
"path": "/src/components/player.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Deserialize, Serialize, PrefabData)]
#[serde(deny_unknown_fields)]
pub struct PlayerPrefabData {
player: Player,
sprite_scene: SpriteScenePrefab,
}<|fim_prefix|>// repo: BloodHaawk/r-shmup_1 path: /src/components/player.rs
use amethyst::{
assets::{PrefabData, ProgressCo... | code_fim | medium | {
"lang": "rust",
"repo": "BloodHaawk/r-shmup_1",
"path": "/src/components/player.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn send<
Request: serde::ser::Serialize + ?Sized,
Response: serde::de::DeserializeOwned,
>(
&mut self,
request: &Request,
) -> Response {
// preflight request
let http_response = self
.client
.request(reqwest::Method... | code_fim | hard | {
"lang": "rust",
"repo": "agabani/foruma",
"path": "/foruma-web/tests/graphql/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: agabani/foruma path: /foruma-web/tests/graphql/mod.rs
use std::collections::HashMap;
#[derive(serde::Deserialize)]
pub struct Response<T> {
pub data: Option<T>,
pub errors: Option<Vec<Error>>,
}
#[derive(serde::Deserialize)]
pub struct Error {
pub message: String,
pub locations... | code_fim | hard | {
"lang": "rust",
"repo": "agabani/foruma",
"path": "/foruma-web/tests/graphql/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ftilde/rust-x86asm path: /src/test/instruction_tests/instr_bndmov.rs
use instruction_def::*;
use test::run_test;
use Operand::*;
use Reg::*;
use RegScale::*;
use RegType::*;
use {BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
#[test]
fn bndmov_1() {
... | code_fim | hard | {
"lang": "rust",
"repo": "ftilde/rust-x86asm",
"path": "/src/test/instruction_tests/instr_bndmov.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_test(
&Instruction {
mnemonic: Mnemonic::BNDMOV,
operand1: Some(Indirect(RCX, Some(OperandSize::Xmmword), None)),
operand2: Some(Direct(BND2)),
operand3: None,
operand4: None,
lock: false,
rounding_mode: No... | code_fim | hard | {
"lang": "rust",
"repo": "ftilde/rust-x86asm",
"path": "/src/test/instruction_tests/instr_bndmov.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ranerp/soulful-companion path: /src/color/rgb.rs
use std::ops::{Sub, Add, Mul};
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Rgb {
pub r: u8,
pub g: u8,
pub b: u8,
}
impl Rgb {
pub fn new(r: u8, g: u8, b: u8) -> Rgb {
Rgb { r, g, b, }
}
pub fn mul... | code_fim | hard | {
"lang": "rust",
"repo": "ranerp/soulful-companion",
"path": "/src/color/rgb.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Rgb {
r: self.r - other.r,
g: self.g - other.g,
b: self.b - other.b,
}
}
}
impl<'a, 'b> Add<&'b Rgb> for &'a Rgb {
type Output = Rgb;
fn add(self, other: &'b Rgb) -> Rgb {
Rgb {
r: self.r + other.r,
g: self.g... | code_fim | hard | {
"lang": "rust",
"repo": "ranerp/soulful-companion",
"path": "/src/color/rgb.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anand-prem/twenty-one-days-of-rust path: /src/day_1.rs
use std::fmt;
pub fn run() {
println!("<<<<<<<<<Day 1>>>>>>>>>");
println!("Print");
println!("=====");
print_simple();
print_self_defined_structure();
print_with_display_trait();
}
fn print_simple() {
println!("==========Pr... | code_fim | medium | {
"lang": "rust",
"repo": "anand-prem/twenty-one-days-of-rust",
"path": "/src/day_1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> struct Point {
x: i32,
y: i32,
}
impl fmt::Display for Point {
fn fmt(&self, f:&mut fmt::Formatter) -> fmt::Result {
write!(f, "Point [{}, {}]", self.x, self.y)
}
}
let point = Point {x: 3, y: 5};
println!("Point is {}", point);
}<|fim_prefix|>// repo: anand-prem/twenty... | code_fim | medium | {
"lang": "rust",
"repo": "anand-prem/twenty-one-days-of-rust",
"path": "/src/day_1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let name = "Alice";
let age = 24;
let alice = Person {name, age};
println!("Person is {:#?}", alice);
}
fn print_with_display_trait() {
println!("==========Print Structure With Defined Structure=========");
struct Point {
x: i32,
y: i32,
}
impl fmt::Display for Point {
fn f... | code_fim | hard | {
"lang": "rust",
"repo": "anand-prem/twenty-one-days-of-rust",
"path": "/src/day_1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vbetivu/codeforces path: /tram/src/main.rs
use std::io;
fn main() {
let mut stops = String::new();
io::stdin().read_line(&mut stops).unwrap();
let stops: u32 = stops.trim().parse().unwrap();
let mut capacity = 0;
let mut current_fill = 0;
let mut stop = String::new()... | code_fim | medium | {
"lang": "rust",
"repo": "vbetivu/codeforces",
"path": "/tram/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut stop_stats = stop.split_whitespace();
let exit: i32 = stop_stats.next().unwrap().parse().unwrap();
let enter: i32 = stop_stats.next().unwrap().parse().unwrap();
current_fill += enter - exit;
if current_fill > capacity {
capacity = current_fill... | code_fim | medium | {
"lang": "rust",
"repo": "vbetivu/codeforces",
"path": "/tram/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dsietz/pbd path: /src/dua/extractor/mod.rs
//! An Extractor that parses the HTTP header and pulls out a list of DUAs
use super::*;
<|fim_suffix|>ix_web;
extern crate futures;
pub mod actix;<|fim_middle|>extern crate actix_service;
extern crate act | code_fim | easy | {
"lang": "rust",
"repo": "dsietz/pbd",
"path": "/src/dua/extractor/mod.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>ix_web;
extern crate futures;
pub mod actix;<|fim_prefix|>// repo: dsietz/pbd path: /src/dua/extractor/mod.rs
//! An Extractor that parses the HTTP header<|fim_middle|> and pulls out a list of DUAs
use super::*;
extern crate actix_service;
extern crate act | code_fim | medium | {
"lang": "rust",
"repo": "dsietz/pbd",
"path": "/src/dua/extractor/mod.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>star4_group_12;
pub mod star4_group_6;
pub mod star4_group_4;
pub struct ListN {
pub min: usize,
pub freq: usize,
}<|fim_prefix|>// repo: mgx0612/lottox path: /src/lotto5/star4/mod.rs
pub mod star4_straight_multi;
pub mod star4_straight_single;
<|fim_middle|>pub mod star4_straight_combo;
pub mod... | code_fim | medium | {
"lang": "rust",
"repo": "mgx0612/lottox",
"path": "/src/lotto5/star4/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub struct ListN {
pub min: usize,
pub freq: usize,
}<|fim_prefix|>// repo: mgx0612/lottox path: /src/lotto5/star4/mod.rs
pub mod star4_straight_multi;
pub mod star4_straight_single;
<|fim_middle|>pub mod star4_straight_combo;
pub mod star4_group_24;
pub mod star4_group_12;
pub mod star4_group_6... | code_fim | medium | {
"lang": "rust",
"repo": "mgx0612/lottox",
"path": "/src/lotto5/star4/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mgx0612/lottox path: /src/lotto5/star4/mod.rs
pub mod star4_straight_multi;
pub mod star4_straight_single;
<|fim_suffix|>
pub struct ListN {
pub min: usize,
pub freq: usize,
}<|fim_middle|>pub mod star4_straight_combo;
pub mod star4_group_24;
pub mod star4_group_12;
pub mod star4_group_6... | code_fim | medium | {
"lang": "rust",
"repo": "mgx0612/lottox",
"path": "/src/lotto5/star4/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tribe-health/wallet.rs path: /wallet/examples/offline_signing/3_send_transaction.rs
// Copyright 2022 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
//! In this example we send the signed transaction in a block.
//! `cargo run --example 3_send_transaction --release`.
use std::{fs::File, ... | code_fim | medium | {
"lang": "rust",
"repo": "tribe-health/wallet.rs",
"path": "/wallet/examples/offline_signing/3_send_transaction.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
async fn read_signed_transaction_from_file<P: AsRef<Path> + Send>(
client: &Client,
path: P,
) -> Result<SignedTransactionData> {
let mut file = File::open(&path)?;
let mut json = String::new();
file.read_to_string(&mut json)?;
let dto = serde_json::from_str::<Signed... | code_fim | hard | {
"lang": "rust",
"repo": "tribe-health/wallet.rs",
"path": "/wallet/examples/offline_signing/3_send_transaction.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gabrielesvelto/api-daemon path: /third-party/backtrace/src/symbolize/gimli/macho.rs
use super::{Context, Mapping, Mmap, Path, Stash, Vec};
use core::convert::TryInto;
use object::macho;
use object::read::macho::{MachHeader, Nlist, Section, Segment as _};
use object::{Bytes, NativeEndian};
#[cfg... | code_fim | hard | {
"lang": "rust",
"repo": "gabrielesvelto/api-daemon",
"path": "/third-party/backtrace/src/symbolize/gimli/macho.rs",
"mode": "psm",
"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.