text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> println!("Tuple: {}, {}, {}", five_hundred, six_point_four, once);
// Array
let a = [1, 2, 3, 4, 5];
let months = ["January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"];
let a: [i32; 5] = [1, 2, 3, 4, ... | code_fim | hard | {
"lang": "rust",
"repo": "sam-g99/Learning-Rust",
"path": "/data_types/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn convert(input: &str) -> Vec<BoardingPass> {
let mut passes = input.lines()
.map(|s| {
BoardingPass::from(s)
})
.collect::<Vec<BoardingPass>>();
passes.sort_unstable();
passes
}
p... | code_fim | hard | {
"lang": "rust",
"repo": "yasinsoenmez/adventofcode_2020",
"path": "/src/days/day5.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yasinsoenmez/adventofcode_2020 path: /src/days/day5.rs
use std::{cmp::Ordering, path::Path};
#[derive(Debug, Eq, PartialOrd)]
pub struct BoardingPass {
seat_id: u32,
row: u32,
col: u32,
}
impl Ord for BoardingPass {
fn cmp(&self, other: &Self) -> Ordering {
self.seat_id... | code_fim | hard | {
"lang": "rust",
"repo": "yasinsoenmez/adventofcode_2020",
"path": "/src/days/day5.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn day5_test() {
let (day5_1, day5_2) = day5();
assert_eq!(day5_1, 953); // 953
assert_eq!(day5_2, 615); // 615
}
#[test]
fn day5_extra() {
let input1 = BoardingPass::from("BFFFBBFRRR");
let input2 = BoardingPass::from("FFFBBBFRRR");
... | code_fim | hard | {
"lang": "rust",
"repo": "yasinsoenmez/adventofcode_2020",
"path": "/src/days/day5.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> sort_units(units);
let width = board[0].len();
let height = board.len();
for i in 0..units.len() {
if !units[i].alive {
continue;
}
let targets = find_targets(i, &units);
// Round ends prematurely
if targets.is_empty() {
re... | code_fim | hard | {
"lang": "rust",
"repo": "karjonas/advent-of-code",
"path": "/2018/day15/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let unit_str = unit_strs.join(", ");
println!("{}", line_str + " " + &unit_str);
y += 1;
}
}
fn find_targets(unit_idx: usize, units: &Vec<Unit>) -> Vec<usize> {
let mut output = Vec::new();
let is_goblin = units[unit_idx].is_goblin;
for i in 0..units.len() {
... | code_fim | hard | {
"lang": "rust",
"repo": "karjonas/advent-of-code",
"path": "/2018/day15/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: karjonas/advent-of-code path: /2018/day15/src/lib.rs
extern crate common;
const INPUT_FILE: &str = "2018/day15/input";
#[derive(Clone, Debug)]
struct Unit {
x: usize,
y: usize,
is_goblin: bool,
health: usize,
alive: bool,
attack: usize,
}
fn sort_units(units: &mut Vec<... | code_fim | hard | {
"lang": "rust",
"repo": "karjonas/advent-of-code",
"path": "/2018/day15/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let world_width = 10_000;
let world_height = 10_000;
for num_agents in [50_000, 100_000, 500_000, 1_000_000] {
group.bench_with_input(BenchmarkId::from_parameter(format!("{}", num_agents)), &num_agents, |b, _| {
b.iter_batched(
setup(world_width, world_heig... | code_fim | hard | {
"lang": "rust",
"repo": "Alfred-Mountfield/rust_tag",
"path": "/benches/update.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Alfred-Mountfield/rust_tag path: /benches/update.rs
use criterion::{BatchSize, BenchmarkId, Criterion, criterion_group, criterion_main};
use rust_tag::world_grid::WorldGrid;
use rust_tag::agents::Agents;
fn setup(world_width: u32, world_height: u32, num_agents: u32) -> Box<dyn FnMut() -> (World... | code_fim | medium | {
"lang": "rust",
"repo": "Alfred-Mountfield/rust_tag",
"path": "/benches/update.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn bench_update_density_large(c: &mut Criterion) {
let mut group = c.benchmark_group("Density - 10_000 x 10_000");
let world_width = 10_000;
let world_height = 10_000;
for num_agents in [50_000, 100_000, 500_000, 1_000_000] {
group.bench_with_input(BenchmarkId::from_parameter(for... | code_fim | hard | {
"lang": "rust",
"repo": "Alfred-Mountfield/rust_tag",
"path": "/benches/update.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> floor_plan.iter().map(|row| row.iter()
.map(|loc| match loc { Location::Seat(true) => 1, _ => 0}).sum::<usize>()).sum()
}
const DAY: u8 = 11;
fn main() -> Result<(), Box<dyn Error>> {
let input = advent_of_code_2020::get_puzzle_input(DAY)?;
println!("Part1: {}", part1(&input));
... | code_fim | hard | {
"lang": "rust",
"repo": "dblinn/advent_of_code_2020",
"path": "/src/bin/day_11.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> const INPUT: &str = "L.LL.LL.LL
LLLLLLL.LL
L.L.L..L..
LLLL.LL.LL
L.LL.LL.LL
L.LLLLL.LL
..L.L.....
LLLLLLLLLL
L.LLLLLL.L
L.LLLLL.LL";
/// the empty seat below would see eight occupied seats:
const EIGHT: &str = ".......#.
...#.....
.#.......
.........
..#L....#
....#....
.........
#........
..... | code_fim | hard | {
"lang": "rust",
"repo": "dblinn/advent_of_code_2020",
"path": "/src/bin/day_11.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dblinn/advent_of_code_2020 path: /src/bin/day_11.rs
#![feature(min_const_generics)]
use std::error::Error;
use std::cmp::{min, max};
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
enum Location {
Seat(bool),
Floor
}
type FloorPlan = Vec<Vec<Location>>;
type Position = (usize, usize);
f... | code_fim | hard | {
"lang": "rust",
"repo": "dblinn/advent_of_code_2020",
"path": "/src/bin/day_11.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if mouse::is_mouse_btn_pressed(&input_state.raw.mouse_state, mouse::Mouse_Button::Left) {
self.hover_data.selected_line = self.hover_data.hovered_line;
self.hover_data.just_selected = true;
} else {
self.hover_data.just_selected = false;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "silverweed/ecsde",
"path": "/inle/inle_debug/src/overlay.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: silverweed/ecsde path: /inle/inle_debug/src/overlay.rs
use super::element::{Debug_Element, Draw_Args, Update_Args, Update_Res};
use inle_alloc::temp;
use inle_cfg::{Cfg_Var, Config};
use inle_common::colors::{self, Color};
use inle_common::stringid::String_Id;
use inle_common::variant::Variant;
... | code_fim | hard | {
"lang": "rust",
"repo": "silverweed/ecsde",
"path": "/inle/inle_debug/src/overlay.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let first_relevant_arg = env::args_os().skip(1).next();
if let Some(arg) = first_relevant_arg {
if let Some(arg) = arg.to_str() {
if arg.starts_with("-") {
if arg == "--bash-setup" {
let exec = env::current_exe().unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "rustonaut/prompty",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustonaut/prompty path: /src/main.rs
extern crate terminfo;
extern crate smallvec;
use std::{
env,
cmp::max
};
use crate::{
iface::*,
process_cwd::process_cwd,
process_git::process_git
};
mod config;
mod iface;
mod plugin_impl;
mod process_cwd;
mod process_git;
fn main(... | code_fim | hard | {
"lang": "rust",
"repo": "rustonaut/prompty",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return Ok(());
}
}
}
Err(())
}
const HELP_MSG: &str =
r#"usage: prompty (--bash-setup|<column_count>)
If `--bash-setup` is passed in a but of bash code
will be emmited which if passed to a `eval` call
will setup `prompty` as promt and add the `g`
command.
No... | code_fim | hard | {
"lang": "rust",
"repo": "rustonaut/prompty",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: little-dude/netlink path: /netlink-packet-route/src/rtnl/tc/constants.rs
// SPDX-License-Identifier: MIT
/// Handles
pub const TC_H_MAJ_MASK: u32 = 0xFFFF0000;
pub const TC_H_MIN_MASK: u32 = 0x0000FFFF;
#[macro_export]
macro_rules! TC_H_MAKE {
($maj: expr, $min: expr) => {
($maj & ... | code_fim | hard | {
"lang": "rust",
"repo": "little-dude/netlink",
"path": "/netlink-packet-route/src/rtnl/tc/constants.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Mirred action attr
pub const TCA_MIRRED_UNSPEC: u16 = 0;
pub const TCA_MIRRED_TM: u16 = 1;
pub const TCA_MIRRED_PARMS: u16 = 2;
pub const TCA_MIRRED_PAD: u16 = 3;
pub const TCA_MIRRED_MAX: u16 = TCA_MIRRED_PAD;
pub const TCA_EGRESS_REDIR: i32 = 1; /* packet redirect to EGRESS */
pub const TCA_EGRESS_... | code_fim | hard | {
"lang": "rust",
"repo": "little-dude/netlink",
"path": "/netlink-packet-route/src/rtnl/tc/constants.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const TC_ACT_JUMP: i32 = 0x10000000;
pub const TCA_ACT_TAB: u16 = 1; // TCA_ROOT_TAB
pub const TCAA_MAX: u16 = 1;
/// Mirred action attr
pub const TCA_MIRRED_UNSPEC: u16 = 0;
pub const TCA_MIRRED_TM: u16 = 1;
pub const TCA_MIRRED_PARMS: u16 = 2;
pub const TCA_MIRRED_PAD: u16 = 3;
pub const TCA_MIRRE... | code_fim | hard | {
"lang": "rust",
"repo": "little-dude/netlink",
"path": "/netlink-packet-route/src/rtnl/tc/constants.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let fcol: Collection<f64> = Collection::from(vec![0.0,0.0]);
let mut col_3v: Collection<ThreeVec> = Collection::empty();
for _i in 0..9 {col_3v.push(ThreeVec::new(1.0,2.0,3.0));}
let mut ttree = Tree::new("Test_Tree");
ttree.add_field("Desc", "This is a Tree for tes... | code_fim | hard | {
"lang": "rust",
"repo": "JTPond/calcify",
"path": "/src/tree/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns Collection from a Trees
///
/// # Arguments
///
/// `key` - String
///
/// # Example
///
/// ```
/// use calcify::Tree;
/// use calcify::Collection;
/// use calcify::Bin;
///
/// let f_col: Collection<f64> = Collection::from(vec![0.0,0.0]... | code_fim | hard | {
"lang": "rust",
"repo": "JTPond/calcify",
"path": "/src/tree/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JTPond/calcify path: /src/tree/mod.rs
use std::collections::HashMap;
use std::error;
mod branch;
pub use branch::Collection;
pub use branch::Bin;
pub use branch::Point;
pub use branch::PointBin;
pub use branch::Branch;
mod feedtree;
pub use feedtree::FeedTree;
use crate::utils;
use utils::{... | code_fim | hard | {
"lang": "rust",
"repo": "JTPond/calcify",
"path": "/src/tree/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tyleo/advent_of_code_2020 path: /src/problem_8_1.rs
use crate::util;
pub fn problem_8_1() -> String {
let file = util::read("input/problem_8_input.txt");
let mut lines = file
.lines()
.m<|fim_suffix|>!lines[ic].0 {
lines[ic].0 = true;
match lines[ic].1 {
... | code_fim | medium | {
"lang": "rust",
"repo": "tyleo/advent_of_code_2020",
"path": "/src/problem_8_1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
ic += 1;
}
"jmp" => ic = (ic as i32 + lines[ic].2) as usize,
_ => {}
}
}
acc.to_string()
}<|fim_prefix|>// repo: tyleo/advent_of_code_2020 path: /src/problem_8_1.rs
use crate::util;
pub fn problem_8_1() -> String {
let file = util... | code_fim | hard | {
"lang": "rust",
"repo": "tyleo/advent_of_code_2020",
"path": "/src/problem_8_1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Trolldemorted/isla path: /web/server/src/request.rs
// BSD 2-Clause License
//
// Copyright (c) 2019, 2020 Alasdair Armstrong
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions ... | code_fim | hard | {
"lang": "rust",
"repo": "Trolldemorted/isla",
"path": "/web/server/src/request.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug)]
pub struct JsGraph {
pub events: Vec<JsEvent>,
pub sets: Vec<JsSet>,
pub relations: Vec<JsRelation>,
pub show: Vec<String>,
}
#[derive(Serialize, Deserialize)]
#[serde(tag = "tag", content = "content")]
pub enum Response {
InternalError,
Er... | code_fim | hard | {
"lang": "rust",
"repo": "Trolldemorted/isla",
"path": "/web/server/src/request.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tene/text-ui path: /src/widget/text.rs
use unicode_segmentation::UnicodeSegmentation;
use widget::Widget;
use Size;
#[derive(Debug, PartialEq, Clone)]
pub struct Text {
pub lines: Vec<String>,
pub style: Option<String>,
}
<|fim_suffix|> let lines: Vec<String> = self.lines
... | code_fim | medium | {
"lang": "rust",
"repo": "tene/text-ui",
"path": "/src/widget/text.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Text {
pub fn new(lines: Vec<String>) -> Text {
Text { lines, style: None }
}
pub fn new_styled(lines: Vec<String>, s: &str) -> Text {
let style = Some(s.to_owned());
Text { lines, style }
}
pub fn push(&mut self, s: String) {
self.lines.extend(s.li... | code_fim | hard | {
"lang": "rust",
"repo": "tene/text-ui",
"path": "/src/widget/text.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jacobrosenthal/usbd-hid path: /macros/src/lib.rs
/ #[item_settings data,variable,relative] x=input;
/// #[item_settings data,variable,relative] y=input;
/// };
/// }
/// )]
/// struct CustomCoords {
/// x: i8,
/// y: i8,
/// }
/// ```
///
/// The above... | code_fim | hard | {
"lang": "rust",
"repo": "jacobrosenthal/usbd-hid",
"path": "/macros/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jacobrosenthal/usbd-hid path: /macros/src/lib.rs
Self::Item>;
fn into_iter(self) -> Self::IntoIter {
self.field_order.into_iter()
}
}
fn try_resolve_constant(key_name: String, path: String) -> Option<u32> {
match (key_name.as_str(), path.as_str()) {
("collection", "... | code_fim | hard | {
"lang": "rust",
"repo": "jacobrosenthal/usbd-hid",
"path": "/macros/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut out = GroupSpec { ..Default::default() };
let fields: Punctuated<Expr, Token![,]> = input.parse_terminated(Expr::parse)?;
if fields.len() == 0 {
return Err(parse::Error::new(input.span(), "`#[gen_hid_descriptor]` expected information about the HID report"));
... | code_fim | hard | {
"lang": "rust",
"repo": "jacobrosenthal/usbd-hid",
"path": "/macros/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: findo/RWLock path: /src/lib.rs
#![allow(dead_code)]
/// reader-writer lock
/// written by Feng Wang
use std::sync::Mutex;
use std::sync::Condvar;
use std::cell::UnsafeCell;
use std::ops::{Deref, DerefMut};
//use std::sync::Arc;
use std::rc::Rc;
//use std::{thread, time};
/// Provides a reader... | code_fim | hard | {
"lang": "rust",
"repo": "findo/RWLock",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
}
/// A write guard for `RwLock`
pub struct RwLockWriteGuard<'a, T: 'a> {
lock : &'a RwLock<T>
}
/// Provides access to the shared object
impl<'a, T> Deref for RwLockWriteGuard<'a, T> {
type Target = T;
fn deref(&self) -> &T {
unsafe {
&*self.lock.data.get()
... | code_fim | hard | {
"lang": "rust",
"repo": "findo/RWLock",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn fetch_page(cameras:&[String], num_per_page:i32, page:i32, minsol:i32, maxsol:i32, thumbnails:bool, list_only:bool, search:&str, only_new:bool) -> error::Result<i32> {
match submit_query(&cameras, num_per_page, Some(page), minsol, maxsol) {
Ok(v) => {
let res: MslApiResults ... | code_fim | hard | {
"lang": "rust",
"repo": "ebelliveau/mars-raw-utils",
"path": "/src/msl/remote.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ebelliveau/mars-raw-utils path: /src/msl/remote.rs
use crate::{
constants,
jsonfetch,
error,
util::*,
msl::metadata::*
};
pub fn print_header() {
println!("{:37} {:15} {:6} {:20} {:27} {:6} {:6} {:7} {:10}",
"ID",
"Instrument... | code_fim | hard | {
"lang": "rust",
"repo": "ebelliveau/mars-raw-utils",
"path": "/src/msl/remote.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Yatekii/stm32mp1-pac path: /src/temp/temp_or.rs
to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12);
self.w
}
}
#[doc = "Reader of field `TS_Op13`"]
pub type TS_OP... | code_fim | hard | {
"lang": "rust",
"repo": "Yatekii/stm32mp1-pac",
"path": "/src/temp/temp_or.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Yatekii/stm32mp1-pac path: /src/temp/temp_or.rs
field `TS_Op22`"]
pub type TS_OP22_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `TS_Op22`"]
pub struct TS_OP22_W<'a> {
w: &'a mut W,
}
impl<'a> TS_OP22_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set... | code_fim | hard | {
"lang": "rust",
"repo": "Yatekii/stm32mp1-pac",
"path": "/src/temp/temp_or.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn renderer(&self) -> &dyn Renderer {
&*self.renderer
}
pub fn renderer_mut(&mut self) -> &mut dyn Renderer {
&mut *self.renderer
}
}<|fim_prefix|>// repo: mintyproof/tea path: /tea/src/engine.rs
use crate::gfx::Renderer;
use crate::platform::Platform;
type PlatformR... | code_fim | medium | {
"lang": "rust",
"repo": "mintyproof/tea",
"path": "/tea/src/engine.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mintyproof/tea path: /tea/src/engine.rs
use crate::gfx::Renderer;
use crate::platform::Platform;
type PlatformRef<'a> = &'a mut (dyn Platform + 'a);
type RendererRef<'a> = &'a mut (dyn Renderer + 'a);
<|fim_suffix|> pub fn renderer(&self) -> &dyn Renderer {
&*self.renderer
}
... | code_fim | hard | {
"lang": "rust",
"repo": "mintyproof/tea",
"path": "/tea/src/engine.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn renderer_mut(&mut self) -> &mut dyn Renderer {
&mut *self.renderer
}
}<|fim_prefix|>// repo: mintyproof/tea path: /tea/src/engine.rs
use crate::gfx::Renderer;
use crate::platform::Platform;
type PlatformRef<'a> = &'a mut (dyn Platform + 'a);
type RendererRef<'a> = &'a mut (dyn Ren... | code_fim | hard | {
"lang": "rust",
"repo": "mintyproof/tea",
"path": "/tea/src/engine.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>extern "C" {
pub fn rb_ary_new_capa(capa: isize) -> VALUE;
pub fn rb_ary_entry(ary: VALUE, offset: isize) -> VALUE;
pub fn rb_ary_push(ary: VALUE, item: VALUE) -> VALUE;
}
extern crate libcruby_sys as sys;
use sys::{VALUE};
use helix::{ToRuby};
struct VecString {
val: Vec<String>
}
impl ... | code_fim | medium | {
"lang": "rust",
"repo": "benolee/ruby_sql_lexer",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benolee/ruby_sql_lexer path: /src/lib.rs
#[macro_use]
extern crate helix;
extern crate sql_lexer;
ruby! {
class RubySqlLexer {
def sanitize_string(buf: String) -> String {
sql_lexer::sanitize_string(buf)
}
def lex(buf: String) -> VecString {
<|fim_suffi... | code_fim | hard | {
"lang": "rust",
"repo": "benolee/ruby_sql_lexer",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ary = unsafe { rb_ary_new_capa(self.val.len() as isize) };
for item in self.val {
unsafe { rb_ary_push(ary, item.to_ruby()); }
}
ary
}
}<|fim_prefix|>// repo: benolee/ruby_sql_lexer path: /src/lib.rs
#[macro_use]
extern crate helix;
extern crate sql_le... | code_fim | hard | {
"lang": "rust",
"repo": "benolee/ruby_sql_lexer",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl B for u32 {
fn method(flag: u32, a: usize) -> usize {
if flag == 0 { 0 } else { <() as B>::method(flag, a) }
}
fn method_self(&self, flag: u32, a: usize) -> usize {
if flag == 0 { 0 } else { ().method_self(flag, a) }
}
}
trait C {
fn method(flag: u32, a: usize) -... | code_fim | hard | {
"lang": "rust",
"repo": "flip1995/rust-clippy",
"path": "/tests/ui/only_used_in_recursion.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flip1995/rust-clippy path: /tests/ui/only_used_in_recursion.rs
#![warn(clippy::only_used_in_recursion)]
//@no-rustfix
fn _simple(x: u32) -> u32 {
x
}
fn _simple2(x: u32) -> u32 {
_simple(x)
}
fn _one_unused(flag: u32, a: usize) -> usize {
if flag == 0 { 0 } else { _one_unused(flag ... | code_fim | hard | {
"lang": "rust",
"repo": "flip1995/rust-clippy",
"path": "/tests/ui/only_used_in_recursion.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Warhorst/telegram_bot_api_parser path: /src/raw_api/raw_method.rs
use crate::raw_api::raw_parameter::RawParameter;
#[derive(Debug)]
pub stru<|fim_suffix|> pub parameters: Vec<RawParameter>
}<|fim_middle|>ct RawMethod {
pub name: String,
| code_fim | easy | {
"lang": "rust",
"repo": "Warhorst/telegram_bot_api_parser",
"path": "/src/raw_api/raw_method.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ct RawMethod {
pub name: String,
pub parameters: Vec<RawParameter>
}<|fim_prefix|>// repo: Warhorst/telegram_bot_api_parser path: /src/raw_api/raw_method.rs
use crate::raw_api::raw_parameter::Ra<|fim_middle|>wParameter;
#[derive(Debug)]
pub stru | code_fim | easy | {
"lang": "rust",
"repo": "Warhorst/telegram_bot_api_parser",
"path": "/src/raw_api/raw_method.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let size = window.inner_size();
let instance = wgpu::Instance::new(wgpu::Backends::PRIMARY);
let surface = unsafe { instance.create_surface(&window) };
let adapter = block_on(instance.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPr... | code_fim | hard | {
"lang": "rust",
"repo": "raum-dellamorte/Petri",
"path": "/src/rendering/display.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raum-dellamorte/Petri path: /src/rendering/display.rs
// Heavily borrowed from Learn-WGPU
// https://github.com/sotrh/learn-wgpu/tree/master/code/showcase/framework
use futures::executor::block_on;
use glam::{vec2, Vec2};
use wgpu::{SurfaceError, SurfaceFrame, TextureView};
use winit::{
eve... | code_fim | hard | {
"lang": "rust",
"repo": "raum-dellamorte/Petri",
"path": "/src/rendering/display.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn resize(&mut self, width: u32, height: u32) {
self.surface_config.width = width;
self.surface_config.height = height;
self.surface.configure(&self.device, &self.surface_config);
}
pub fn get_frame(&self) -> Result<(SurfaceFrame, TextureView), SurfaceError> {
... | code_fim | hard | {
"lang": "rust",
"repo": "raum-dellamorte/Petri",
"path": "/src/rendering/display.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn poll_close(&self) -> Poll<Result<(), Fail>> {
self.cb.poll_close()
}
pub fn remote_mss(&self) -> usize {
self.cb.remote_mss()
}
pub fn current_rto(&self) -> Duration {
self.cb.rto()
}
pub fn endpoints(&self) -> (SocketAddrV4, SocketAddrV4) {
... | code_fim | hard | {
"lang": "rust",
"repo": "jthelin/demikernel",
"path": "/src/rust/inetstack/protocols/tcp/established/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jthelin/demikernel path: /src/rust/inetstack/protocols/tcp/established/mod.rs
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
mod background;
pub mod congestion_control;
mod ctrlblk;
mod rto;
mod sender;
pub use self::ctrlblk::{
ControlBlock,
State,
};
use c... | code_fim | hard | {
"lang": "rust",
"repo": "jthelin/demikernel",
"path": "/src/rust/inetstack/protocols/tcp/established/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let event_loop = event_loop::EventLoop::<Window>::new_any_thread();
let size = trace_none!(trace_err!(WindowBuilder::new()
.with_visible(false)
.build(&event_loop))?
.primary_monitor())?
.size();
Ok((size.width, size.height))
}<|fim_prefix|>// repo: maxer456/ALVR path:... | code_fim | hard | {
"lang": "rust",
"repo": "maxer456/ALVR",
"path": "/alvr/common/src/graphics.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxer456/ALVR path: /alvr/common/src/graphics.rs
use crate::prelude::*;
use gfx_hal::Instance;
#[cfg(any(windows, target_os = "linux"))]
pub fn get_gpu_names() -> Vec<String> {
#[cfg(windows)]
let instance = gfx_backend_dx11::Instance::create("ALVR", 0).unwrap();
#[cfg(target_os = "... | code_fim | hard | {
"lang": "rust",
"repo": "maxer456/ALVR",
"path": "/alvr/common/src/graphics.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: p4ddy1/gbemulator path: /gbemulator/src/graphics/gui/controls_window.rs
use crate::config::config::Config;
use crate::config::controls::KeyboardMap;
use crate::graphics::gui::State;
use lib_gbemulation::io::joypad::Key;
use std::sync::{Arc, RwLock};
use winit::event::{ElementState, KeyboardInpu... | code_fim | hard | {
"lang": "rust",
"repo": "p4ddy1/gbemulator",
"path": "/gbemulator/src/graphics/gui/controls_window.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let col4 = ui.get_mut(3).unwrap();
create_clear_button(&self.config, col4, &mut self.text_input_b, Key::B);
create_clear_button(&self.config, col4, &mut self.text_input_down, Key::Down);
create_clear_button(&self.config, col4... | code_fim | hard | {
"lang": "rust",
"repo": "p4ddy1/gbemulator",
"path": "/gbemulator/src/graphics/gui/controls_window.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gitter-badger/wezterm path: /src/font/coretext.rs
//! We'll put macOS Core Text stuff in here
use config::{Config, TextStyle};
use failure::Error;
use font::{FontSystem, NamedFont};
pub type FontSystemImpl = CoreTextSystem;
pub struct CoreTextSystem {}
<|fim_suffix|>impl FontSystem for CoreTe... | code_fim | medium | {
"lang": "rust",
"repo": "gitter-badger/wezterm",
"path": "/src/font/coretext.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FontSystem for CoreTextSystem {
fn load_font(&self, config: &Config, style: &TextStyle) -> Result<Box<NamedFont>, Error> {
bail!("load_font");
}
}<|fim_prefix|>// repo: gitter-badger/wezterm path: /src/font/coretext.rs
//! We'll put macOS Core Text stuff in here
use config::{Config, ... | code_fim | medium | {
"lang": "rust",
"repo": "gitter-badger/wezterm",
"path": "/src/font/coretext.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn with_alu_op(mut self, alu_op: ALUOperation) -> Descriptor
{
self.alu_op = Some(alu_op);
self
}
pub(crate) fn with_mem_access(mut self, mem_access: MemoryAccess) -> Descriptor
{
self.mem_access = Some(mem_access);
self
}
}<|fim_prefix|>// repo: JayTee42/rusty-mimasim path: /sr... | code_fim | hard | {
"lang": "rust",
"repo": "JayTee42/rusty-mimasim",
"path": "/src/microcycle/descriptor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JayTee42/rusty-mimasim path: /src/microcycle/descriptor.rs
use crate::types::{*, Registers as Regs};
use crate::bus::Xfer as BusXfer;
use crate::unit::{ALUOperation, MemoryAccess};
// A microcycle descriptor encapsulates an optional bus transfer, an optional ALU signal and an optional memory si... | code_fim | medium | {
"lang": "rust",
"repo": "JayTee42/rusty-mimasim",
"path": "/src/microcycle/descriptor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Michel-Haber/ts-mem-pool path: /src/arc_recycled.rs
use std::sync::Arc;
use std::sync::mpsc;
use std::ops::Deref;
use std::ops::DerefMut;
/// This trait is required to use
/// a type in the memory pool
pub trait Recycle {
/// Render data of the object usable
///
/// # Example
//... | code_fim | hard | {
"lang": "rust",
"repo": "Michel-Haber/ts-mem-pool",
"path": "/src/arc_recycled.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Channel to recv recycled data
let (tx, rx) = mpsc::channel();
/// New scope for adding values
{
let mut rec = ArcRecycled::new(Vec::<f64>::with_capacity(50), tx);
for _ in 0..10 {
rec.push(5.0);
}
}
/... | code_fim | hard | {
"lang": "rust",
"repo": "Michel-Haber/ts-mem-pool",
"path": "/src/arc_recycled.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jfarrell468/isim path: /src/config.rs
use serde::{Deserialize, Serialize};
use std::option::Option;
#[derive(Serialize, Deserialize, Debug)]
pub struct InitialBalance {
pub pre_tax: Allocation,
pub roth: Allocation,
pub after_tax: Allocation,
pub after_tax_cost_basis: Option<f64... | code_fim | hard | {
"lang": "rust",
"repo": "jfarrell468/isim",
"path": "/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug)]
pub enum InflationAdjustment {
Real,
Nominal,
}
#[derive(Serialize, Deserialize, Debug)]
pub enum ReportField {
YearsElapsed,
WorstYears,
Value(Measure, AccountType, InflationAdjustment),
BondPercent(AccountType),
CapGainsPercent,
S... | code_fim | hard | {
"lang": "rust",
"repo": "jfarrell468/isim",
"path": "/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kurnos/adventofcode2020 path: /src/day01.rs
use crate::infra;
pub struct Day1;
impl infra::Problem<String, String, u32, u32, 1> for Day1 {
fn first(contents: String) -> u32 {
find_target(&parse_numbers(contents), 2020).unwrap()
}
fn second(contents: String) -> u32 {
... | code_fim | hard | {
"lang": "rust",
"repo": "kurnos/adventofcode2020",
"path": "/src/day01.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn find_target(data: &[u32], target: u32) -> Option<u32> {
let mut low = 0usize;
let mut high = data.len() - 1;
while low < high {
match data[low] + data[high] {
d if d == target => {
return Some(data[low] * data[high]);
}
d if d < ta... | code_fim | hard | {
"lang": "rust",
"repo": "kurnos/adventofcode2020",
"path": "/src/day01.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bastion-rs/allocator-suite path: /src/memory_sources/arena_memory_source/slot_index.rs
#[derive(Default, Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
pub struct SlotIndex(pub usize);
<|fim_suffix|> #[inline(always)]
pub(crate) fn increment(&mut self) {
self.0 += 1
... | code_fim | hard | {
"lang": "rust",
"repo": "bastion-rs/allocator-suite",
"path": "/src/memory_sources/arena_memory_source/slot_index.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline(always)]
pub(crate) fn increment(&mut self) {
self.0 += 1
}
}<|fim_prefix|>// repo: bastion-rs/allocator-suite path: /src/memory_sources/arena_memory_source/slot_index.rs
#[derive(Default, Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
pub struct SlotIndex(pub usi... | code_fim | hard | {
"lang": "rust",
"repo": "bastion-rs/allocator-suite",
"path": "/src/memory_sources/arena_memory_source/slot_index.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn overwrite(&mut self, _element: T) {
unimplemented!("Write the passed element to the CircularBuffer, overwriting the existing elements if CircularBuffer is full.");
}
}<|fim_prefix|>// repo: exercism/rust path: /exercises/practice/circular-buffer/src/lib.rs
pub struct CircularBuffer... | code_fim | hard | {
"lang": "rust",
"repo": "exercism/rust",
"path": "/exercises/practice/circular-buffer/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: exercism/rust path: /exercises/practice/circular-buffer/src/lib.rs
pub struct CircularBuffer<T> {
// We fake using T here, so the compiler does not complain that
// "parameter `T` is never used". Delete when no longer needed.
phantom: std::marker::PhantomData<T>,
}
#[derive(Debug, P... | code_fim | medium | {
"lang": "rust",
"repo": "exercism/rust",
"path": "/exercises/practice/circular-buffer/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 3..n + 1 {
let new_val = mem[0] + mem[1];
mem[0] = mem[1];
mem[1] = new_val;
}
mem[1]
}<|fim_prefix|>// repo: EduardoSantos7/Algorithms4fun path: /AlgoExpert/Nth Fibonacci/solution3.rs
fn main() {
println!("val: {}", get_nth_fib(5));
}
fn get_nth_fib(n: i... | code_fim | medium | {
"lang": "rust",
"repo": "EduardoSantos7/Algorithms4fun",
"path": "/AlgoExpert/Nth Fibonacci/solution3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EduardoSantos7/Algorithms4fun path: /AlgoExpert/Nth Fibonacci/solution3.rs
fn main() {
println!("val: {}", get_nth_fib(5));
}
fn get_nth_fib(n: i32) -> i32 {
let mut mem = vec![0, 1];
<|fim_suffix|> for _ in 3..n + 1 {
let new_val = mem[0] + mem[1];
mem[0] = mem[1];
... | code_fim | medium | {
"lang": "rust",
"repo": "EduardoSantos7/Algorithms4fun",
"path": "/AlgoExpert/Nth Fibonacci/solution3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if n < 3 {
return mem[(n - 1) as usize];
}
for _ in 3..n + 1 {
let new_val = mem[0] + mem[1];
mem[0] = mem[1];
mem[1] = new_val;
}
mem[1]
}<|fim_prefix|>// repo: EduardoSantos7/Algorithms4fun path: /AlgoExpert/Nth Fibonacci/solution3.rs
fn main() {
... | code_fim | medium | {
"lang": "rust",
"repo": "EduardoSantos7/Algorithms4fun",
"path": "/AlgoExpert/Nth Fibonacci/solution3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // add jokers to deck
new_deck.deck.extend([Card::Joker; 4].iter());
// shuffle
new_deck.deck.shuffle(&mut thread_rng());
new_deck
}
// moves card to dealt vector and returns it
// reshuffling if the deck is empty
pub fn draw(&mut self) -> Card {
... | code_fim | hard | {
"lang": "rust",
"repo": "theZiggurat/card-game",
"path": "/src/deck.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theZiggurat/card-game path: /src/deck.rs
use crate::card::{Card, Suit, Face};
use rand::prelude::*;
// the deck holds all cards in the deck
// and all cards already dealt
pub struct Deck {
pub deck: Vec<Card>,
pub dealt: Vec<Card>
}
impl Deck {
// returns new deck with 56 card... | code_fim | hard | {
"lang": "rust",
"repo": "theZiggurat/card-game",
"path": "/src/deck.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // moves card to dealt vector and returns it
// reshuffling if the deck is empty
pub fn draw(&mut self) -> Card {
if self.deck.is_empty() {
self.reshuffle();
}
let card = self.deck.remove(0);
self.dealt.push(card);
card
}
// moves al... | code_fim | hard | {
"lang": "rust",
"repo": "theZiggurat/card-game",
"path": "/src/deck.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mukundbhudia/rs-challenges path: /tests/iq_test.rs
// From: https://www.codewars.com/kata/552c028c030765286c00007d/train/rust
pub fn iq_test(numbers: &str) -> u64 {
let mut evens = vec![];
let mut odds = vec![];
for pair in numbers
.split_whitespace()
.filter_map(|x... | code_fim | medium | {
"lang": "rust",
"repo": "mukundbhudia/rs-challenges",
"path": "/tests/iq_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(iq_test("2 4 7 8 10"), 3);
assert_eq!(iq_test("1 2 2"), 1);
assert_eq!(iq_test("1 2 1 1"), 2);
}
}<|fim_prefix|>// repo: mukundbhudia/rs-challenges path: /tests/iq_test.rs
// From: https://www.codewars.com/kata/552c028c030765286c00007d/train/rust
pub fn iq_test(num... | code_fim | medium | {
"lang": "rust",
"repo": "mukundbhudia/rs-challenges",
"path": "/tests/iq_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod digital_root_tests {
use super::*;
#[test]
fn general_tests() {
assert_eq!(iq_test("2 4 7 8 10"), 3);
assert_eq!(iq_test("1 2 2"), 1);
assert_eq!(iq_test("1 2 1 1"), 2);
}
}<|fim_prefix|>// repo: mukundbhudia/rs-challenges path: /tests/iq_test.rs
/... | code_fim | medium | {
"lang": "rust",
"repo": "mukundbhudia/rs-challenges",
"path": "/tests/iq_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danielgallagher0/bluetooth-hci path: /src/types/connection_interval.rs
//! Types related to the connection interval.
use byteorder::{ByteOrder, LittleEndian};
use core::cmp;
use core::time::Duration;
/// Define a connection interval range with its latency and supervision timeout. This value is... | code_fim | hard | {
"lang": "rust",
"repo": "danielgallagher0/bluetooth-hci",
"path": "/src/types/connection_interval.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Sets the connection latency.
///
/// # Errors
///
/// There are no errors from this function, but it may cause errors in
/// [build](ConnectionIntervalBuilder::build) if:
/// - `latency` is 500 or greater.
/// - `latency` leads to an invalid relative supervision timeout... | code_fim | hard | {
"lang": "rust",
"repo": "danielgallagher0/bluetooth-hci",
"path": "/src/types/connection_interval.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ruma/ruma path: /crates/ruma-federation-api/src/space.rs
//! Spaces endpoints.
use js_int::UInt;
use ruma_common::{
room::RoomType, serde::Raw, space::SpaceRoomJoinRule, OwnedMxcUri, OwnedRoomAliasId,
OwnedRoomId,
};
use ruma_events::space::child::HierarchySpaceChildEvent;
use serde::{D... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/ruma",
"path": "/crates/ruma-federation-api/src/space.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The join rule of the room.
pub join_rule: SpaceRoomJoinRule,
/// If the room is a restricted room, these are the room IDs which are specified by the join
/// rules.
pub allowed_room_ids: Vec<OwnedRoomId>,
}
impl From<SpaceHierarchyChildSummaryInit> for SpaceHierarchyChildSummary ... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/ruma",
"path": "/crates/ruma-federation-api/src/space.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Whether guest users may join the room and participate in it.
///
/// If they can, they will be subject to ordinary power level rules like any other user.
pub guest_can_join: bool,
/// The join rule of the room.
pub join_rule: SpaceRoomJoinRule,
/// If the room is a restri... | code_fim | hard | {
"lang": "rust",
"repo": "ruma/ruma",
"path": "/crates/ruma-federation-api/src/space.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
//! Previous fire times:
//! prev -> 2022-07-01T15:30:00Z
//! prev -> 2022-07-01T12:30:00Z
//! prev -> 2022-07-01T09:30:00Z
//! prev -> 2022-06-15T15:30:00Z
//! prev -> 2022-06-15T12:30:00Z
//! prev -> 2022-06-15T09:30:00Z
//! prev -> 2022-06-01T15:30:00Z
//! prev -> 2022-06-01T12:30:00Z
//! prev -> 2022... | code_fim | hard | {
"lang": "rust",
"repo": "rust-playground/cron-exp",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-playground/cron-exp path: /src/lib.rs
//! # Schedule
//!
//! Is a CRON expression parser and explorer.
//!
//! It Supports both Crantab and Vixie CRON. If 5 arguments are provided Crantab is assumed,
//! otherwise Vixie CRON.
//!
//! The following Syntax is supported:
//! - \* any value
//!... | code_fim | hard | {
"lang": "rust",
"repo": "rust-playground/cron-exp",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> note_txt -> Nullable<Text>,
}
}<|fim_prefix|>// repo: MawKKe/rust-massa-tracker path: /src/schema.rs
table! {
massaa (id) {
id -> Nullable<Integer>,
ts -> Nullable<T<|fim_middle|>imestamp>,
kg -> Nullable<Float>,
| code_fim | easy | {
"lang": "rust",
"repo": "MawKKe/rust-massa-tracker",
"path": "/src/schema.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MawKKe/rust-massa-tracker path: /src/schema.rs
table! {
massaa (id) {
id -> Nullable<Integer>,
ts -> Nullable<T<|fim_suffix|> note_txt -> Nullable<Text>,
}
}<|fim_middle|>imestamp>,
kg -> Nullable<Float>,
| code_fim | easy | {
"lang": "rust",
"repo": "MawKKe/rust-massa-tracker",
"path": "/src/schema.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MawKKe/rust-massa-tracker path: /src/schema.rs
table! {
massaa (id) {
id -> N<|fim_suffix|>imestamp>,
kg -> Nullable<Float>,
note_txt -> Nullable<Text>,
}
}<|fim_middle|>ullable<Integer>,
ts -> Nullable<T | code_fim | easy | {
"lang": "rust",
"repo": "MawKKe/rust-massa-tracker",
"path": "/src/schema.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Xyon/rust-RIBBIT path: /src/client.rs
#![allow(warnings)]
use std::io::Read;
use hyper::header::Headers;
use hyper::Client;
use std::collections::HashMap;
use decoder;
pub struct frog_tip {
tip_id: u64,
tip: String,
}
pub struct RIBBITClient {
url: String,
headers: Headers,
client: C... | code_fim | medium | {
"lang": "rust",
"repo": "Xyon/rust-RIBBIT",
"path": "/src/client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn it_works() {
let mut frog = super::RIBBITClient::new();
let tip = frog.frog_tip();
assert!(tip.len() > 0 && tip.contains("FROG"));
}
}<|fim_prefix|>// repo: Xyon/rust-RIBBIT path: /src/client.rs
#![allow(warnings)]
use std::io::Read;
use hyper::header::Headers;
use hyper::Cl... | code_fim | hard | {
"lang": "rust",
"repo": "Xyon/rust-RIBBIT",
"path": "/src/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return say.unwrap();
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let mut frog = super::RIBBITClient::new();
let tip = frog.frog_tip();
assert!(tip.len() > 0 && tip.contains("FROG"));
}
}<|fim_prefix|>// repo: Xyon/rust-RIBBIT path: /src/client.rs
#![all... | code_fim | hard | {
"lang": "rust",
"repo": "Xyon/rust-RIBBIT",
"path": "/src/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let line = "[2017/11/24 21:26:00] <time> [sop_1912 ([ERF] SOP :-))] 0:23.75";
let dt = Utc.ymd(2017, 11, 24).and_hms(21, 26, 00);
let from = "sop_1912".to_string();
let nick = "[ERF] SOP :-)".to_string();
let duration = Duration::milliseconds(23750);
let li... | code_fim | hard | {
"lang": "rust",
"repo": "ptillemans/trackmania",
"path": "/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ptillemans/trackmania path: /src/parser.rs
use chrono::prelude::*;
use regex::Regex;
use time::Duration;
#[derive(PartialEq, Eq, Debug)]
pub enum Line {
Chat {
ts: DateTime<Utc>,
from: String,
to: String,
message: String,
},
Time {
ts: DateTim... | code_fim | hard | {
"lang": "rust",
"repo": "ptillemans/trackmania",
"path": "/src/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
line,
Line::Chat {
ts: dt,
from: from,
to: to,
message: "".to_string()
}
)
}
#[test]
fn parse_loading_line() {
let line =
"[2017/11/24 22:52:47] ... | code_fim | hard | {
"lang": "rust",
"repo": "ptillemans/trackmania",
"path": "/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn generate_random_secret() -> String {
random_token(SECRET_LENGTH)
}
pub async fn create(client: NewClient, db: &DbConn) -> Result<Client> {
client.validate()?;
let client = NewClientWithSecret {
name: client.name,
secret: Self::generate_random_secret(),
};
db.run(move |conn| {
c... | code_fim | hard | {
"lang": "rust",
"repo": "ZeusWPI/zauth",
"path": "/src/models/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZeusWPI/zauth path: /src/models/client.rs
use diesel::{self, prelude::*};
use crate::errors::{AuthenticationError, Result, ZauthError};
use crate::DbConn;
use self::schema::clients;
use crate::util::random_token;
use chrono::NaiveDateTime;
use validator::Validate;
const SECRET_LENGTH: usize ... | code_fim | hard | {
"lang": "rust",
"repo": "ZeusWPI/zauth",
"path": "/src/models/client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub async fn find(id: i32, db: &DbConn) -> Result<Client> {
let client = db
.run(move |conn| clients::table.find(id).first(conn))
.await?;
Ok(client)
}
pub fn redirect_uri_acceptable(&self, redirect_uri: &str) -> bool {
self.redirect_uri_list
.lines()
.any(|uri| uri == redirect_uri)
... | code_fim | hard | {
"lang": "rust",
"repo": "ZeusWPI/zauth",
"path": "/src/models/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.