text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>impl IndexMut<Tuple2d> for Array2D { #[inline] fn index_mut(&mut self, idx: Tuple2d) -> &mut f64 { let (i, j) = idx; &mut self.data[i + self.size_x * j] } } impl IndexMut<usize> for Array2D { #[inline] fn index_mut(&mut self, idx: usize) -> &mut f64 { &mut self...
code_fim
hard
{ "lang": "rust", "repo": "Debilski/simple-benchmarks", "path": "/rust/rd2d/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Alo81/prc-rs path: /src/lib/lib.rs mod asm; mod disasm; pub mod param; #[cfg(feature = "xml")] pub mod xml; use std::fs::{read, write}; use std::io::{Cursor, Error, Read, Seek, Write}; use std::path::Path; pub use hash40; pub use strum; <|fim_suffix|>pub fn save<P: AsRef<Path>>(filepath: P, p...
code_fim
hard
{ "lang": "rust", "repo": "Alo81/prc-rs", "path": "/src/lib/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn read_stream<R>(reader: &mut R) -> Result<param::ParamStruct, Error> where R: Read + Seek, { disasm::disassemble(reader) } pub fn write_stream<W>(writer: &mut W, param_struct: &param::ParamStruct) -> Result<(), Error> where W: Write + Seek, { asm::assemble(writer, param_struct) } p...
code_fim
medium
{ "lang": "rust", "repo": "Alo81/prc-rs", "path": "/src/lib/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doubleduck98/uni path: /rust/lista4/zad1/src/main.rs fn main() { println!("{}", find_digit(5673, 4)); } fn find_digit(num: i32, nth: i32) -> i32 { if nth <= 0 { return -1; } else if num.to_string().len() < (nth as usize) { return 0; } (num.abs() / (10 as...
code_fim
hard
{ "lang": "rust", "repo": "doubleduck98/uni", "path": "/rust/lista4/zad1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(find_digit(799131105, 5), 3); } #[test] fn test9() { assert_eq!(find_digit(-5125, 1), 5); }<|fim_prefix|>// repo: doubleduck98/uni path: /rust/lista4/zad1/src/main.rs fn main() { println!("{}", find_digit(5673, 4)); } fn find_digit(num: i32, nth: i32) -> i32 { <|fim_middle|> if...
code_fim
hard
{ "lang": "rust", "repo": "doubleduck98/uni", "path": "/rust/lista4/zad1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>hort("R") .long("recursive") .multiple(true) .help("Recurse into directories"), ) .arg( Arg::with_name("tree") .long("tree") .multiple(true) .help("Recurse into directories and prese...
code_fim
hard
{ "lang": "rust", "repo": "boxdot/lsd", "path": "/src/app.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: boxdot/lsd path: /src/app.rs use clap::{App, Arg}; pub fn build() -> App<'static, 'static> { App::new("lsd") .version(crate_version!()) .about("An ls comment with a lot of pretty colors and some other stuff.") .arg(Arg::with_name("FILE").multiple(true).default_value(...
code_fim
hard
{ "lang": "rust", "repo": "boxdot/lsd", "path": "/src/app.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>sify") .multiple(true) .help("Append indicator (one of */=>@|) at the end of the file names"), ) .arg( Arg::with_name("long") .short("l") .long("long") .multiple(true) .help("Display...
code_fim
hard
{ "lang": "rust", "repo": "boxdot/lsd", "path": "/src/app.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn datacarrying_mixed() { check_discriminants( r#" #[repr(u8)] enum Enum { Variant(), // ^^^^^^^^^ = 0 Variant1, // ^^^^^^^^ = 1 Variant2 {}, // ^^^^^^^^^^^ = 2 Variant3, // ^^^^^^^^ = 3 Variant5 = 5, Variant6, // ^^^^^^^^ = 6 } "#, ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust-analyzer", "path": "/crates/ide/src/inlay_hints/discriminant.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust-analyzer path: /crates/ide/src/inlay_hints/discriminant.rs //! Implementation of "enum variant discriminant" inlay hints: //! ```no_run //! enum Foo { //! Bar/* = 0*/, //! } //! ``` use hir::Semantics; use ide_db::{base_db::FileId, famous_defs::FamousDefs, RootDatabase}; use sy...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust-analyzer", "path": "/crates/ide/src/inlay_hints/discriminant.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joseluis/toru-rs path: /examples/cube.rs use mutunga::{Cell, Color as TermColor, Event, TerminalCanvas}; use nalgebra as na; use std::f32::consts::PI; use std::{thread, time}; use toru::{Camera, Canvas, Color, Cube, DrawContext}; struct CubeScene { camera: Camera, cube: Cube, } impl CubeScen...
code_fim
hard
{ "lang": "rust", "repo": "joseluis/toru-rs", "path": "/examples/cube.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // We're going to render to the terminal let mut term = TerminalCanvas::new(); let width = term.width(); let height = term.height(); // Create a scene with just a single cube. let mut scene = CubeScene { camera: Camera::new(width as _, height as _), cube: Cube::new(1.0, Color::rgb(0, 100, 255))...
code_fim
hard
{ "lang": "rust", "repo": "joseluis/toru-rs", "path": "/examples/cube.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: slinkydeveloper/extending-kubernetes-api-in-process-poc path: /kube-rs/src/runtime/mod.rs //! Legacy runtime helpers for keeping track of Kubernete<|fim_suffix|> pub use informer::Informer; pub use reflector::Reflector;<|fim_middle|>s resources //! //! Please see the `kube-runtime` crate for the...
code_fim
medium
{ "lang": "rust", "repo": "slinkydeveloper/extending-kubernetes-api-in-process-poc", "path": "/kube-rs/src/runtime/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub use informer::Informer; pub use reflector::Reflector;<|fim_prefix|>// repo: slinkydeveloper/extending-kubernetes-api-in-process-poc path: /kube-rs/src/runtime/mod.rs //! Legacy runtime helpers for keeping track of Kubernetes resources //! //! Please see the `kube-runtime` crate fo<|fim_middle|>r the...
code_fim
easy
{ "lang": "rust", "repo": "slinkydeveloper/extending-kubernetes-api-in-process-poc", "path": "/kube-rs/src/runtime/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: awsdocs/aws-doc-sdk-examples path: /rust_dev_preview/examples/tls/tests/test-tls.rs /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserve<|fim_suffix|>] async fn test_it_runs() { match tls::connect_via_tls_13().await { Err(_e) => assert!(false), _ => assert!(...
code_fim
medium
{ "lang": "rust", "repo": "awsdocs/aws-doc-sdk-examples", "path": "/rust_dev_preview/examples/tls/tests/test-tls.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Err(_e) => assert!(false), _ => assert!(true), } }<|fim_prefix|>// repo: awsdocs/aws-doc-sdk-examples path: /rust_dev_preview/examples/tls/tests/test-tls.rs /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserve<|fim_middle|>d. * SPDX-License-Identifier: Apache-2.0. ...
code_fim
medium
{ "lang": "rust", "repo": "awsdocs/aws-doc-sdk-examples", "path": "/rust_dev_preview/examples/tls/tests/test-tls.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: grogers0/advent_of_code path: /2018/day9/src/main.rs use std::io::{self, Read}; use lazy_static::lazy_static; use linked_list::{LinkedList, Cursor}; use regex::Regex; // (players, last marble) fn parse(input: &str) -> (usize, usize) { lazy_static!{ static ref RE: Regex = Regex::new...
code_fim
hard
{ "lang": "rust", "repo": "grogers0/advent_of_code", "path": "/2018/day9/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (num_players, last_marble) = parse(input); calc(num_players, last_marble) } fn part2(input: &str) -> usize { let (num_players, last_marble) = parse(input); calc(num_players, last_marble * 100) } fn main() { let mut input = String::new(); io::stdin().read_to_string(&mut input)...
code_fim
hard
{ "lang": "rust", "repo": "grogers0/advent_of_code", "path": "/2018/day9/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (num_players, last_marble) = parse(input); calc(num_players, last_marble * 100) } fn main() { let mut input = String::new(); io::stdin().read_to_string(&mut input).unwrap(); println!("{}", part1(&input)); println!("{}", part2(&input)); } #[cfg(test)] mod tests { use sup...
code_fim
hard
{ "lang": "rust", "repo": "grogers0/advent_of_code", "path": "/2018/day9/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhongsp/code-kata path: /LeetCode/rs/1-50/valid_sudoku.rs //! https://leetcode-cn.com/problems/valid-sudoku/ use std::collections::HashMap; struct Solution; #[allow(dead_code)] impl Solution { pub fn is_valid_sudoku(board: Vec<Vec<char>>) -> bool { let mut rows = vec![HashMap::new...
code_fim
hard
{ "lang": "rust", "repo": "zhongsp/code-kata", "path": "/LeetCode/rs/1-50/valid_sudoku.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if rows[i].contains_key(&val) { return false; } else { rows[i].insert(val, 0); } if columns[j].contains_key(&val) { return false; } else { column...
code_fim
hard
{ "lang": "rust", "repo": "zhongsp/code-kata", "path": "/LeetCode/rs/1-50/valid_sudoku.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn in_order(node: &Node) -> Vec<i32> { let mut list = vec![]; let mut stack = vec![Cont::Init(node)]; while let Some(frame) = stack.pop() { match frame { Cont::Init(Node::Empty) => {} Cont::Init(Node::Node(v, l, r)) => { stack.push(Cont::Right(*v...
code_fim
hard
{ "lang": "rust", "repo": "danzhu/prototypes", "path": "/rec_to_stack.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let tree = Node::new(1, Node::leaf(2), Node::new(3, Node::leaf(4), Node::empty())); let list = in_order(&tree); println!("{:?}", list); }<|fim_prefix|>// repo: danzhu/prototypes path: /rec_to_stack.rs enum Node { Node(i32, Box<Node>, Box<Node>), Empty, } impl Node { fn new(val: i...
code_fim
hard
{ "lang": "rust", "repo": "danzhu/prototypes", "path": "/rec_to_stack.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danzhu/prototypes path: /rec_to_stack.rs enum Node { Node(i32, Box<Node>, Box<Node>), Empty, } impl Node { fn new(val: i32, left: Node, right: Node) -> Node { <|fim_suffix|>enum Cont<'a> { Init(&'a Node), Right(i32, &'a Node), } fn in_order(node: &Node) -> Vec<i32> { le...
code_fim
hard
{ "lang": "rust", "repo": "danzhu/prototypes", "path": "/rec_to_stack.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (i, parameter_declare) in arguments.into_iter().enumerate() { let parameter_value = match function.get_nth_param(i as u32) { Some(val) => val.into_int_value(), None => panic!(), }; let identifier = parameter_declare.get_identi...
code_fim
hard
{ "lang": "rust", "repo": "sinato/rcc2", "path": "/src/parser/node/function.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sinato/rcc2 path: /src/parser/node/function.rs use inkwell::types::BasicTypeEnum; use crate::emitter::emitter::Emitter; use crate::emitter::environment::{IntVariable, Variable}; use crate::lexer::token::{Token, Tokens}; use crate::parser::node::declare::DeclareNode; use crate::parser::node::sta...
code_fim
hard
{ "lang": "rust", "repo": "sinato/rcc2", "path": "/src/parser/node/function.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn get(&self, x: i32, y: i32, n: usize) -> Option<i32> { self.coords[(x - 1 + (y - 1) * self.size) as usize][n - 1] } fn set(&mut self, x: i32, y: i32, n: usize, pow: i32) { self.coords[(x - 1 + (y - 1) * self.size) as usize][n - 1] = Some(pow); } fn get_or_calc(&mut ...
code_fim
hard
{ "lang": "rust", "repo": "madmax28/aoc2018", "path": "/day11/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn set(&mut self, x: i32, y: i32, n: usize, pow: i32) { self.coords[(x - 1 + (y - 1) * self.size) as usize][n - 1] = Some(pow); } fn get_or_calc(&mut self, x: i32, y: i32, n: usize) -> i32 { if let Some(pow) = self.get(x, y, n) { pow } else { se...
code_fim
hard
{ "lang": "rust", "repo": "madmax28/aoc2018", "path": "/day11/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: madmax28/aoc2018 path: /day11/src/main.rs use std::cmp::max; use std::iter::repeat; fn calc_power(x: i32, y: i32, serial: i32) -> i32 { ((x + 10) * y + serial) * (x + 10) / 100 % 10 - 5 } #[derive(Debug)] struct Grid { size: i32, serial: i32, coords: Vec<Vec<Option<i32>>>, } i...
code_fim
hard
{ "lang": "rust", "repo": "madmax28/aoc2018", "path": "/day11/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 7sDream/amiya path: /src/middleware/router/set_which.rs use { crate::{middleware::router::RouterLike, Middleware}, std::borrow::Cow, }; pub trait SetWhich<Ex> { fn set_to_target<R, M>(self, router: R, middleware: M) -> R where R: RouterLike<Ex>, M: Middleware<Ex>...
code_fim
hard
{ "lang": "rust", "repo": "7sDream/amiya", "path": "/src/middleware/router/set_which.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> where R: RouterLike<Ex>, M: Middleware<Ex> + 'static, { router.insert_to_router_table(self.path, middleware); router } }<|fim_prefix|>// repo: 7sDream/amiya path: /src/middleware/router/set_which.rs use { crate::{middleware::router::RouterLike, Middleware},...
code_fim
hard
{ "lang": "rust", "repo": "7sDream/amiya", "path": "/src/middleware/router/set_which.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(PartialEq, Eq, Debug, Clone)] struct HubInner { id: String, message_count: u64, }<|fim_prefix|>// repo: avranju/quota-manager-sample path: /src/hub.rs use std::{cell::RefCell, rc::Rc}; #[derive(PartialEq, Eq, Debug, Clone)] pub struct Hub { state: Rc<RefCell<HubInner>>, } impl Hub ...
code_fim
hard
{ "lang": "rust", "repo": "avranju/quota-manager-sample", "path": "/src/hub.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: avranju/quota-manager-sample path: /src/hub.rs use std::{cell::RefCell, rc::Rc}; #[derive(PartialEq, Eq, Debug, Clone)] pub struct Hub { state: Rc<RefCell<HubInner>>, } impl Hub { pub fn new(id: String) -> Self { Hub { state: Rc::new(RefCell::new(HubInner { ...
code_fim
hard
{ "lang": "rust", "repo": "avranju/quota-manager-sample", "path": "/src/hub.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SheilaCecilia/dataflow-join path: /naive/src/bin/q2-star.rs extern crate timely; extern crate naive; use naive::{GraphMap, intersect_and}; fn main () { <|fim_suffix|> let mut count: usize = 0; let mut prefix = Vec::new(); let mut v1 = index; while v1 < graph.nod...
code_fim
hard
{ "lang": "rust", "repo": "SheilaCecilia/dataflow-join", "path": "/naive/src/bin/q2-star.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut count: usize = 0; let mut prefix = Vec::new(); let mut v1 = index; while v1 < graph.nodes() { let v1f = graph.forward(v1); for &v3 in v1f.iter() { intersect_and(graph.edges(v1), graph.edges(v3), |x| prefix.push(x)); ...
code_fim
medium
{ "lang": "rust", "repo": "SheilaCecilia/dataflow-join", "path": "/naive/src/bin/q2-star.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let timer = std::time::Instant::now(); let index = root.index() as u32; let peers = root.peers() as u32; let graph = GraphMap::new(&filename); let mut count: usize = 0; let mut prefix = Vec::new(); let mut v1 = index; while v1 < graph.nodes(...
code_fim
medium
{ "lang": "rust", "repo": "SheilaCecilia/dataflow-join", "path": "/naive/src/bin/q2-star.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: traianscrob/schedul3r path: /src/lib.rs use chrono::{DateTime, Duration, Local}; use std::sync::{Arc, Mutex}; use timer::Timer; use std::sync::mpsc::channel; use std::{any::type_name, thread}; use dict::{ Dict, DictIface }; use crossbeam_utils::thread as other_thread; //types type TimerCallback...
code_fim
hard
{ "lang": "rust", "repo": "traianscrob/schedul3r", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn scheduler_works() { let mut scheduler = ScheduleManager::instance(); let mut test = TestCall::new(); let callback = move |_| { println!("test executed!"); assert_eq!(test.increment(), 1); }; scheduler.execute(move || { as...
code_fim
hard
{ "lang": "rust", "repo": "traianscrob/schedul3r", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: grogers0/advent_of_code path: /2015/day4/src/main.rs use std::io::{self, Read}; use crypto::digest::Digest; use crypto::md5::Md5; fn md5(input: &str) -> String { let mut digest = Md5::new(); digest.input_str(input); digest.result_str() } fn first_md5_suffix_with_leading_zeros(inpu...
code_fim
hard
{ "lang": "rust", "repo": "grogers0/advent_of_code", "path": "/2015/day4/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // NOTE - make sure to use cargo test --release or it will take forever #[test] fn test_part1() { assert_eq!(part1("abcdef"), 609043); assert_eq!(part1("pqrstuv"), 1048970); } }<|fim_prefix|>// repo: grogers0/advent_of_code path: /2015/day4/src/main.rs use std::io::{self, ...
code_fim
hard
{ "lang": "rust", "repo": "grogers0/advent_of_code", "path": "/2015/day4/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: io12/Sandvox path: /src/input.rs use glium::glutin::{ DeviceEvent, ElementState, Event, KeyboardInput, MouseButton, VirtualKeyCode, WindowEvent, }; use cgmath::prelude::*; use cgmath::Vector3; use clamp::clamp; use rand::prelude::*; use std::f32::consts::PI; use std::time::SystemTime; u...
code_fim
hard
{ "lang": "rust", "repo": "io12/Sandvox", "path": "/src/input.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if state.player.state == PlayerState::Running { state.player.state = PlayerState::Normal; state.timers.since_run_timer = Some(SystemTime::now()); } } // Change game state based on a key release. This is needed because `do_keys_down()` only knows if // a key is currently down. fn d...
code_fim
hard
{ "lang": "rust", "repo": "io12/Sandvox", "path": "/src/input.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jamougha/hyper path: /examples/client.rs extern crate hyper; use std::os; use std::io::stdout; use std::io::util::copy; use hyper::Url; use hyper::client::Request; fn main() { let args = os::args(); match args.len() { 2 => (), _ => { println!("Usage: client...
code_fim
hard
{ "lang": "rust", "repo": "jamougha/hyper", "path": "/examples/client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("Response: {}", res.status); println!("{}", res.headers); match copy(&mut res, &mut stdout()) { Ok(..) => (), Err(e) => panic!("Stream failure: {}", e) }; }<|fim_prefix|>// repo: jamougha/hyper path: /examples/client.rs extern crate hyper; use std::os; use std::...
code_fim
hard
{ "lang": "rust", "repo": "jamougha/hyper", "path": "/examples/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Comment { pub fn from_row(row: &rows::Row) -> Comment { return Comment { id: row.get("id"), user_id: row.get("user_id"), publication_datetime: row.get("publication_datetime"), edition_datetime: row.get("edition_datetime") }; } } ...
code_fim
hard
{ "lang": "rust", "repo": "dnp1/api", "path": "/src/article/common.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Content { content: String } impl Content { pub fn from_row(row: &rows::Row) -> Content { return Content { content: row.get("content"), }; } }<|fim_prefix|>// repo: dnp1/api path...
code_fim
hard
{ "lang": "rust", "repo": "dnp1/api", "path": "/src/article/common.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dnp1/api path: /src/article/common.rs use uuid::Uuid; use postgres::rows; use chrono::NaiveDateTime; #[derive(Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Article { id: Uuid, title: String, publication_datetime: NaiveDateTime, edition_datetime: N...
code_fim
hard
{ "lang": "rust", "repo": "dnp1/api", "path": "/src/article/common.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: filmor/eir path: /compiler/src/ir/lir/pass/simplify_branches.rs //use ::parser::AtomicLiteral; //use ::ir::SSAVariable; //use ::ir::lir::{ BasicBlock, OpKind, Source, FunctionCfg }; //use ::std::collections::HashMap; use ::eir::{ AtomicTerm, ConstantTerm }; use ::eir::Atom; use ::eir::op::OpKind...
code_fim
hard
{ "lang": "rust", "repo": "filmor/eir", "path": "/compiler/src/ir/lir/pass/simplify_branches.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn merge_jump_chains(b: &mut FunctionBuilder) { let cfg = b.function().gen_cfg(); // Find candidate jumps // Candidate jumps: // - The first ebb ends with a Jump op // - The second ebb only has a single incoming edge let mut args_buf = Vec::new(); for node_idx in cfg.graph.nod...
code_fim
hard
{ "lang": "rust", "repo": "filmor/eir", "path": "/compiler/src/ir/lir/pass/simplify_branches.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Find incoming edges to target, only go ahead if // there is only a single edge. let mut edges_iter = cfg.graph.edges_directed( target_ebb_idx, Direction::Incoming); let first_edge = edges_iter.next(); le...
code_fim
hard
{ "lang": "rust", "repo": "filmor/eir", "path": "/compiler/src/ir/lir/pass/simplify_branches.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<Var> From<Vec<String>> for Element<Var> where Var: VariableFormat, { fn from(value: Vec<String>) -> Element<Var> { Element::Inner(value.into_iter().map(Element::Literal).collect()) } } impl<Var> ToString for Element<Var> where Var: VariableFormat, { fn to_string(&self) ->...
code_fim
hard
{ "lang": "rust", "repo": "udoprog/codeviz", "path": "/common/src/element.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Element::Inner(value.into_iter().map(Element::Literal).collect()) } } impl<Var> ToString for Element<Var> where Var: VariableFormat, { fn to_string(&self) -> String { let mut s = String::new(); let mut extra = Var::Extra::default(); self.format(&mut ElementForm...
code_fim
hard
{ "lang": "rust", "repo": "udoprog/codeviz", "path": "/common/src/element.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: udoprog/codeviz path: /common/src/element.rs use super::*; #[derive(Debug, Clone)] pub enum Element<Var> where Var: VariableFormat, { Push(Statement<Var>), Concat(Statement<Var>), Literal(String), Inner(Vec<Element<Var>>), Nested(Box<Element<Var>>), Spacing, } impl<...
code_fim
hard
{ "lang": "rust", "repo": "udoprog/codeviz", "path": "/common/src/element.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Cactice/rust_sdl2_opengl_emscripten path: /src/gl/vao.rs use super::*; pub struct Vao { pub gl_handle: types::GLuint, /// Store a Rc to the Gl instance to ensure that we can destroy this resource when dropped gl: std::rc::Rc<Gl>, } impl Vao { pub fn new( pointer_definiti...
code_fim
hard
{ "lang": "rust", "repo": "Cactice/rust_sdl2_opengl_emscripten", "path": "/src/gl/vao.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Drop for Vao { fn drop(&mut self) { unsafe { self.gl.DeleteVertexArrays(1, &self.gl_handle as *const _); } } } pub struct VertexAttributeDefinition { pub dimension_count: u8, pub data_type: u32, pub normalized: bool, pub stride: u32, pub offset:...
code_fim
hard
{ "lang": "rust", "repo": "Cactice/rust_sdl2_opengl_emscripten", "path": "/src/gl/vao.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for _ in 0..threads { let header = header.clone(); let do_send_until_error = do_send_until_error(addr, header).map_err(|e| { eprint!("{}", e); std::process::exit(1); }); tokio::task::spawn(do_send_until_error); } Ok(()) } #[tokio::main]...
code_fim
hard
{ "lang": "rust", "repo": "snow2flying/trojan-lite", "path": "/src/bin/perf.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: snow2flying/trojan-lite path: /src/bin/perf.rs use std::{ io, net::SocketAddr, sync::{ atomic::{AtomicUsize, Ordering}, Arc, }, }; use futures::TryFutureExt; use tokio::{ io::{AsyncReadExt, AsyncWriteExt}, net::{TcpListener, TcpStream}, }; use bytes::Buf...
code_fim
hard
{ "lang": "rust", "repo": "snow2flying/trojan-lite", "path": "/src/bin/perf.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[tokio::main] async fn main() { let opts: Options = argh::from_env(); let addr = "127.0.0.1:28078".parse().unwrap(); let amt = Arc::new(AtomicUsize::default()); let dummy = amt.clone(); if let Err(e) = perf( opts.thread, opts.trojan_server_addr, addr, &...
code_fim
hard
{ "lang": "rust", "repo": "snow2flying/trojan-lite", "path": "/src/bin/perf.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `DBG_TIM10_STOP` writer - TIM10 counter stopped when core is halted"] pub struct DBG_TIM10_STOP_W<'a> { w: &'a mut W, } impl<'a> DBG_TIM10_STOP_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.b...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f410/dbgmcu/apb2_fz.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f410/dbgmcu/apb2_fz.rs #[doc = "Register `APB2_FZ` reader"] pub struct R(crate::R<APB2_FZ_SPEC>); impl core::ops::Deref for R { type Target = crate::R<APB2_FZ_SPEC>; #[inline(always)] fn deref(&self) -> ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rustc-perf", "path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f410/dbgmcu/apb2_fz.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if count > my_max { my_max = count; max_val = i; } } return max_val; }<|fim_prefix|>// repo: Akavall/ProjectEulerRust path: /src/project_euler_14.rs use std::collections::HashMap; pub fn project_euler_14(my_num: i64) -> i64 { // using i64 because i32 ...
code_fim
hard
{ "lang": "rust", "repo": "Akavall/ProjectEulerRust", "path": "/src/project_euler_14.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Akavall/ProjectEulerRust path: /src/project_euler_14.rs use std::collections::HashMap; pub fn project_euler_14(my_num: i64) -> i64 { // using i64 because i32 overflows // The solution is actually faster without // the HashMap! let mut my_map: HashMap<i64, i64> = HashMap::new()...
code_fim
hard
{ "lang": "rust", "repo": "Akavall/ProjectEulerRust", "path": "/src/project_euler_14.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> "#EXT-X-BYTERANGE:713084@1110328\n", "#EXTINF:10,\n", "hls_450k_video.ts\n", "#EXT-X-BYTERANGE:476580@1823412\n", "#EXTINF:10,\n", "hls_450k_video.ts\n", "#EXT-X-BYTERANGE:535612@2299992\n", "#EXTINF:10,\n", ...
code_fim
hard
{ "lang": "rust", "repo": "dholroyd/hls_m3u8", "path": "/tests/media_playlist.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dholroyd/hls_m3u8 path: /tests/media_playlist.rs //! Some tests of this file are from //! <https://github.com/videojs/m3u8-parser/tree/master/test/fixtures/m3u8> //! //! TODO: the rest of the tests use std::time::Duration; use hls_m3u8::tags::{ExtInf, ExtXByteRange}; use hls_m3u8::types::Playl...
code_fim
hard
{ "lang": "rust", "repo": "dholroyd/hls_m3u8", "path": "/tests/media_playlist.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn amplify<E: Executor + 'static>(exec: E, remaining: u64) { black_box(do_work(POST_WORK)); if (remaining > 0) { let amp_exec = exec.clone(); exec.execute(move || amplify(amp_exec, remaining - 1)); } black_box(do_work(PRE_WORK)); } fn amplify_finish<E: Executor + 'static>(...
code_fim
hard
{ "lang": "rust", "repo": "x0f5c3/rust-executors", "path": "/executor-performance/src/latency_experiment.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: x0f5c3/rust-executors path: /executor-performance/src/latency_experiment.rs // Copyright 2017 Lars Kroll. See the LICENSE // file at the top-level directory of this distribution. // // Licensed under the MIT license // <LICENSE or http://opensource.org/licenses/MIT>. // This file may not be copi...
code_fim
hard
{ "lang": "rust", "repo": "x0f5c3/rust-executors", "path": "/executor-performance/src/latency_experiment.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_message_amplification(&mut self, n: u64) -> &mut Self { self.message_amplification = n; self } pub fn sleep_time(&self) -> &Duration { &self.sleep_time } pub fn set_sleep_time(&mut self, t: Duration) -> &mut Self { self.sleep_time = t; ...
code_fim
hard
{ "lang": "rust", "repo": "x0f5c3/rust-executors", "path": "/executor-performance/src/latency_experiment.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Generates a window function within the given range for the given window /// size. pub fn generate<F, S, R>(range: R, size: usize) -> Window<S> where F: Function, S: SampleMut, R: Range { let mut output = Window::new(&range, size); // Check the range are valid for the window. debug_a...
code_fim
hard
{ "lang": "rust", "repo": "meh/rft", "path": "/src/window/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: meh/rft path: /src/window/mod.rs mod range; pub use self::range::Range; mod window; pub use self::window::Window; mod rectangular; pub use self::rectangular::Rectangular; mod triangular; pub use self::triangular::Triangular; mod bartlett; pub use self::bartlett::Bartlett; mod parzen; pub us...
code_fim
hard
{ "lang": "rust", "repo": "meh/rft", "path": "/src/window/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} /// Computes the window function for the given index and window size. #[inline(always)] pub fn compute<F, S>(index: usize, width: usize) -> S where F: Function, S: SampleMut { let mut result = S::zero(); result.set_normalized(F::compute(index as Precision, width as Precision)); result } //...
code_fim
hard
{ "lang": "rust", "repo": "meh/rft", "path": "/src/window/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sheets = excel.sheet_names().to_owned(); let mut count = 0; for s in sheets { count += excel .worksheet_range(&s) .unwrap() .unwrap() .rows() .flat_map(|r| r.iter()) .count(); } count } #[bench] fn ben...
code_fim
medium
{ "lang": "rust", "repo": "tafia/calamine", "path": "/benches/basic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tafia/calamine path: /benches/basic.rs #![feature(test)] extern crate test; use calamine::{open_workbook, Ods, Reader, Xls, Xlsb, Xlsx}; use std::fs::File; use std::io::BufReader; use test::Bencher; fn count<R: Reader<BufReader<File>>>(path: &str) -> usize { let path = format!("{}/{}", en...
code_fim
medium
{ "lang": "rust", "repo": "tafia/calamine", "path": "/benches/basic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let right_kind = self.type_expr(unary.right.as_mut()); let type_kind = match (&unary.operation, right_kind) { (UnaryOp::Minus, TypeKind::Int) => { TypeKind::Int } _ => { match right_kind { TypeKind::Err...
code_fim
hard
{ "lang": "rust", "repo": "curtisxk38/rcheer", "path": "/src/typechecker.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: curtisxk38/rcheer path: /src/typechecker.rs use std::mem; use crate::{ast::{Binary, BinaryOp, Expr, Grouping, If, Literal, LiteralType, Unary, UnaryOp}}; pub struct TypeError { pub message: String, } pub enum TypeResult { Success, Error } pub struct TypeChecker { pub errors: ...
code_fim
hard
{ "lang": "rust", "repo": "curtisxk38/rcheer", "path": "/src/typechecker.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let type_kind = if let Some(else_branch) = &mut if_expr.else_branch { let else_type = self.type_expr(else_branch.as_mut()); let type_kind = if std::mem::discriminant(&then_type) == std::mem::discriminant(&else_type) { then_type } else { ...
code_fim
hard
{ "lang": "rust", "repo": "curtisxk38/rcheer", "path": "/src/typechecker.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn is_dup<D>(dataset: &D, new_gen_cover: &D::Cover, pre_set: &D::ItemSet) -> bool where D: DataSet, for<'a> &'a D::ItemSet: IntoIterator<Item = usize> { for item in pre_set.into_iter() { if dataset.supports(item, &new_gen_cover) { return true; } } false }<|fim_prefix|>// repo: gahag/dci ...
code_fim
hard
{ "lang": "rust", "repo": "gahag/dci", "path": "/src/closed.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if support == transactions_count { closed.add(i); } else if support >= min_sup { post.add(i); } } Self { closed, pre, post } } } pub fn is_dup<D>(dataset: &D, new_gen_cover: &D::Cover, pre_set: &D::ItemSet) -> bool where D: DataSet, for<'a> &'a D::ItemSet: IntoIterator<Item =...
code_fim
medium
{ "lang": "rust", "repo": "gahag/dci", "path": "/src/closed.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gahag/dci path: /src/closed.rs use crate::{ DataSet, ItemSet, }; /// The initial sets for the algorithm. pub struct InitialSets<ItemSet> { /// Itemset with all items that occur in all transactions. pub closed: ItemSet, /// Always empty. pub pre: ItemSet, /// Itemset with all frequent it...
code_fim
hard
{ "lang": "rust", "repo": "gahag/dci", "path": "/src/closed.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let instrs = vec![ Instr::movq(Arg::int(10), Arg::var("x.1")), Instr::negq(Arg::var("x.1")), Instr::movq(Arg::var("x.1"), Arg::var("x.2")), Instr::movq(Arg::int(52), Arg::var("x.2")), Instr::movq(Arg::var("x.2"), Arg::reg(Register::Rax)),...
code_fim
hard
{ "lang": "rust", "repo": "patrickcsullivan/eoc", "path": "/src/pxir/assign_homes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn moves_and_neg() { let instrs = vec![ Instr::movq(Arg::int(10), Arg::var("x.1")), Instr::negq(Arg::var("x.1")), Instr::movq(Arg::var("x.1"), Arg::var("x.2")), Instr::movq(Arg::int(52), Arg::var("x.2")), Instr::movq(Arg::...
code_fim
hard
{ "lang": "rust", "repo": "patrickcsullivan/eoc", "path": "/src/pxir/assign_homes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: patrickcsullivan/eoc path: /src/pxir/assign_homes.rs use super::*; struct Ctx { /// Space needed for stack variables in bytes. stack_space: i64, /// Maps symbols to its storage location in the stack frame. Storage /// location is represented as an offset in bytes from the base ...
code_fim
hard
{ "lang": "rust", "repo": "patrickcsullivan/eoc", "path": "/src/pxir/assign_homes.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mspiegel/rust-yaar path: /src/bplus/mod.rs Box::new(LeafNode { keys: newkeys, vals: newvals, })) } else { InsertResult::None } } ...
code_fim
hard
{ "lang": "rust", "repo": "mspiegel/rust-yaar", "path": "/src/bplus/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Generate a RemoveResult that stores a value fn generate(node: &Node, min: usize, val: i32) -> RemoveResult { if node.needs_merge(min) { RemoveResult::Shrink(val) } else { RemoveResult::NoShrink(val) } } } #[cfg(test)] mod tests { use sup...
code_fim
hard
{ "lang": "rust", "repo": "mspiegel/rust-yaar", "path": "/src/bplus/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Get the partition key associated with a child node to be merged. /// The partition key is used when merging internal nodes and is /// unused when merging leaf nodes. fn get_parent_key(&self, index: usize, ord: Sibling) -> i32 { match ord { Sibling::Less => self.keys...
code_fim
hard
{ "lang": "rust", "repo": "mspiegel/rust-yaar", "path": "/src/bplus/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kage-Yami/dynamic-dns-client-for-cloudflare path: /src/api/ip.rs use anyhow::Context; use std::net::{Ipv4Addr, Ipv6Addr}; use std::str::FromStr; use ureq::{Request, Response}; #[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)] pub struct Client { fetch_v4: fn(Request) -> Result<Response, ur...
code_fim
hard
{ "lang": "rust", "repo": "Kage-Yami/dynamic-dns-client-for-cloudflare", "path": "/src/api/ip.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut client = api::ip::Client::new(); client.fetch_v4 = mock_v4; assert_eq!(client.v4().context("failed to fetch mock IPv4 address")?, Ipv4Addr::LOCALHOST); Ok(()) } #[test] fn v6() -> anyhow::Result<()> { let mut client = api::ip::Client::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "Kage-Yami/dynamic-dns-client-for-cloudflare", "path": "/src/api/ip.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(client.v4().context("failed to fetch mock IPv4 address")?, Ipv4Addr::LOCALHOST); Ok(()) } #[test] fn v6() -> anyhow::Result<()> { let mut client = api::ip::Client::new(); client.fetch_v6 = mock_v6; assert_eq!(client.v6().context("failed to ...
code_fim
hard
{ "lang": "rust", "repo": "Kage-Yami/dynamic-dns-client-for-cloudflare", "path": "/src/api/ip.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sunshowers/cargo-guppy path: /guppy/src/unit_tests/reversed_tests.rs // Copyright (c) The cargo-guppy Contributors // SPDX-License-Identifier: MIT OR Apache-2.0 //! These tests are for the additional functionality added to ReversedDirected. The base //! implementation is the same as `petgraph::...
code_fim
hard
{ "lang": "rust", "repo": "sunshowers/cargo-guppy", "path": "/guppy/src/unit_tests/reversed_tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Check that incoming edges in the reversed graph are the same as outgoing edges in the // normal graph, with directions reversed. let mut incoming: Vec<_> = graph .edges_directed(source, Incoming) .map(source_target) .collect(); incomin...
code_fim
hard
{ "lang": "rust", "repo": "sunshowers/cargo-guppy", "path": "/guppy/src/unit_tests/reversed_tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(outgoing, reversed_incoming, "outgoing = reversed incoming"); // Check that incoming edges in the reversed graph are the same as outgoing edges in the // normal graph, with directions reversed. let mut incoming: Vec<_> = graph .edges_directed(source,...
code_fim
hard
{ "lang": "rust", "repo": "sunshowers/cargo-guppy", "path": "/guppy/src/unit_tests/reversed_tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pkg(&self) -> PKG_R { PKG_R::new((self.bits & 0x0f) as u8) } }<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32h7/src/stm32h753/syscfg/pkgr.rs #[doc = "Reader of register PKGR"] pub type R = crate::R<u32, super::PKGR<|fim_middle|>>; #[doc = "Reader of field `PKG`"] pub type...
code_fim
medium
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32h7/src/stm32h753/syscfg/pkgr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32h7/src/stm32h753/syscfg/pkgr.rs #[doc = "Reader of register PKGR"] pub type R = crate::R<u32, super::PKGR>; #[doc = "Reader of field `PKG`"] pub type PKG_R = crate::R<u8, u8>; imp<|fim_suffix|>pkg(&self) -> PKG_R { PKG_R::new((self.bits & 0x0f...
code_fim
medium
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32h7/src/stm32h753/syscfg/pkgr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match session.status() { SessionStatus::Changed | SessionStatus::Renewed => { self.config.set_cookie_value( &cookie_jar, &serde_json::to_string(&session.entries()).unwrap_or_default(), ); } ...
code_fim
hard
{ "lang": "rust", "repo": "happysalada/poem", "path": "/poem/src/session/cookie_session.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: happysalada/poem path: /poem/src/session/cookie_session.rs use std::{collections::BTreeMap, sync::Arc}; use crate::{ middleware::{CookieJarManager, CookieJarManagerEndpoint}, session::{CookieConfig, Session, SessionStatus}, Endpoint, Middleware, Request, }; /// Middleware for clien...
code_fim
hard
{ "lang": "rust", "repo": "happysalada/poem", "path": "/poem/src/session/cookie_session.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> client.call(&app, 7).await; client.call(&app, 6).await; client.assert_cookies(vec![("poem-session", r#"{"a":"10","b":"20","c":"30"}"#)]); client.call(&app, 3).await; client.assert_cookies(vec![("poem-session", r#"{"a":"10","c":"30"}"#)]); client.call(&app...
code_fim
hard
{ "lang": "rust", "repo": "happysalada/poem", "path": "/poem/src/session/cookie_session.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rsnively/scryfall-rs path: /src/card/border_color.rs //! Enum defining the colors a mtg card border can have. use serde::{Deserialize, Serialize}; /// Enum defining the colors a mtg card border can have. #[derive(Serialize, Deserialize, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]...
code_fim
medium
{ "lang": "rust", "repo": "rsnively/scryfall-rs", "path": "/src/card/border_color.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl std::fmt::Display for BorderColour { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { use BorderColour::*; write!( f, "{}", match self { Black => "black", Borderless => "borderless", ...
code_fim
medium
{ "lang": "rust", "repo": "rsnively/scryfall-rs", "path": "/src/card/border_color.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let name = atoms.get(&n as &str).cloned().unwrap_or_else(|| { let name: Arc<str> = Arc::from(n); atoms.insert(name.clone()); name }); let mut args = Vec::new(); for arg in a { args.push(arg.to_ast(atoms, scope)); } ...
code_fim
hard
{ "lang": "rust", "repo": "remexre/fall", "path": "/src/cst.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: remexre/fall path: /src/cst.rs use std::collections::{HashMap, HashSet}; use std::str::FromStr; use std::sync::Arc; use ast; use util::gensym; /// A convenient alias for a LALRPOP parse error. pub type ParseError = ::lalrpop_util::ParseError<usize, (usize, String), &'static str>; #[derive(Clo...
code_fim
hard
{ "lang": "rust", "repo": "remexre/fall", "path": "/src/cst.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn from_str(s: &str) -> Result<$name, ParseError> { use grammar::Token; ::grammar::$parser::new() .parse(s).map_err(|e| e.map_token(|Token(n, s)| (n, s.to_string()))) } } }; ($(($name:ident, $parser:ident)),*) => {...
code_fim
hard
{ "lang": "rust", "repo": "remexre/fall", "path": "/src/cst.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }