text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: rossmacarthur/rust path: /src/test/ui/typeck/hang-in-overflow.rs // normalize-stderr-test "the requirement `.*`" -> "the requirement `...`" // normalize-stderr-test "required for `.*` to implement `.*`" -> "required for `...` to implement `...`" // normalize-stderr-test: ".*the full type name ha...
code_fim
medium
{ "lang": "rust", "repo": "rossmacarthur/rust", "path": "/src/test/ui/typeck/hang-in-overflow.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>where Vec<[[[B; 1]; 1]; 1]>: PartialEq<B>, { } fn main() {}<|fim_prefix|>// repo: rossmacarthur/rust path: /src/test/ui/typeck/hang-in-overflow.rs // normalize-stderr-test "the requirement `.*`" -> "the requirement `...`" // normalize-stderr-test "required for `.*` to implement `.*`" -> "required fo...
code_fim
medium
{ "lang": "rust", "repo": "rossmacarthur/rust", "path": "/src/test/ui/typeck/hang-in-overflow.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> let mut i = a.len() - 1; while i > 0 && a[section_6_1_heaps::parent(i)] > a[i] { a.swap(i, section_6_1_heaps::parent(i)); i = section_6_1_heaps::parent(i); } } #[cfg(test)] mod tests { #[test] fn test_heap_minimum() { assert_eq!(super::heap_minimum(&[1]), &1);...
code_fim
hard
{ "lang": "rust", "repo": "EFanZh/Introduction-to-Algorithms", "path": "/src/chapter_6_heapsort/section_6_5_priority_queues/exercises/exercise_6_5_3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn run_single_test(mut a: Vec<i32>, i: usize, key: i32, expected: &[i32]) { super::heap_decrease_key(&mut a, i, key); assert_eq!(a.as_slice(), expected); } run_single_test(vec![7], 0, 0, &[0]); run_single_test(vec![7, 8], 0, 1, &[1, 8]); r...
code_fim
hard
{ "lang": "rust", "repo": "EFanZh/Introduction-to-Algorithms", "path": "/src/chapter_6_heapsort/section_6_5_priority_queues/exercises/exercise_6_5_3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ield_name; pub(crate) mod field_alias; pub(crate) mod field_name;<|fim_prefix|>// repo: apllodb/apllodb path: /apllodb-sql-processor/src/field.rs //! A field is a part of a record. //! Types of fields are: //! /<|fim_middle|>/! - attribute in correlation (denoted as `correlation.attribute`). //! - consta...
code_fim
medium
{ "lang": "rust", "repo": "apllodb/apllodb", "path": "/apllodb-sql-processor/src/field.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apllodb/apllodb path: /apllodb-sql-processor/src/field.rs //! A field is a part of a record. //! Types of fields are: //! //! - attribute in correlation (denoted as `correlation.attribute`<|fim_suffix|>ield_name; pub(crate) mod field_alias; pub(crate) mod field_name;<|fim_middle|>). //! - consta...
code_fim
medium
{ "lang": "rust", "repo": "apllodb/apllodb", "path": "/apllodb-sql-processor/src/field.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>). //! - constant (e.g. `777`, `"abc"). pub(crate) mod aliased_field_name; pub(crate) mod field_alias; pub(crate) mod field_name;<|fim_prefix|>// repo: apllodb/apllodb path: /apllodb-sql-processor/src/field.rs //! A field is a part of a record. //! Types of fields are: //! /<|fim_middle|>/! - attribute ...
code_fim
medium
{ "lang": "rust", "repo": "apllodb/apllodb", "path": "/apllodb-sql-processor/src/field.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let ioctl_request_type = match &env::var("CARGO_CFG_TARGET_ENV").expect("CARGO_CFG_TARGET_ENV")[..] { "musl" => "libc::c_int", _ => "libc::c_ulong", }; let ioctl_include = ioctl_dir.join("ioctl.rs"); File::create(&ioctl_include) .unwrap() .write_all(IOCTL_I...
code_fim
hard
{ "lang": "rust", "repo": "thecoshman/http", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thecoshman/http path: /build.rs extern crate embed_resource; #[cfg(not(any(target_os = "windows", target_os = "macos")))] extern crate cc; #[cfg(not(any(target_os = "windows", target_os = "macos")))] use std::env; #[cfg(not(any(target_os = "windows", target_os = "macos")))] use std::io::Write; ...
code_fim
hard
{ "lang": "rust", "repo": "thecoshman/http", "path": "/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shepmaster/snafu path: /tests/no_context.rs use snafu::prelude::*; #[derive(Debug, Snafu)] enum AlphaError { AlphaDummy, } #[derive(Debug, Snafu)] enum BetaError { BetaDummy, } #[derive(Debug, Snafu)] enum Error { #[snafu(context(false))] Alpha { source: AlphaError }, #[s...
code_fim
hard
{ "lang": "rust", "repo": "shepmaster/snafu", "path": "/tests/no_context.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn implements_error() { check::<Error>(); assert_eq!(12, example().unwrap()); } mod with_backtraces { use super::*; use snafu::Backtrace; #[derive(Debug, Snafu)] enum Error { #[snafu(context(false))] Alpha { source: AlphaError, ba...
code_fim
hard
{ "lang": "rust", "repo": "shepmaster/snafu", "path": "/tests/no_context.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>mod with_backtraces { use super::*; use snafu::Backtrace; #[derive(Debug, Snafu)] enum Error { #[snafu(context(false))] Alpha { source: AlphaError, backtrace: Backtrace, }, } #[test] fn implements_error() { check::<Error...
code_fim
hard
{ "lang": "rust", "repo": "shepmaster/snafu", "path": "/tests/no_context.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DigitalChiller/glitch-in-the-matrix path: /src/types.rs //! Types used in the Matrix API. //! //! Will be better documented in the future; for now, //! refer to the official API docs for info on what fields mean. use std::collections::HashMap; /// Information about an image. #[derive(Serialize,...
code_fim
hard
{ "lang": "rust", "repo": "DigitalChiller/glitch-in-the-matrix", "path": "/src/types.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> pub age: Option<u64>, pub content: Content, #[serde(default)] pub prev_content: Option<Content>, #[serde(default)] pub state_key: Option<String> } /// Events in a room. #[derive(Serialize, Deserialize, Default, Debug)] pub struct Events { pub events: Vec<Event> } /// Information ...
code_fim
hard
{ "lang": "rust", "repo": "DigitalChiller/glitch-in-the-matrix", "path": "/src/types.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|>commended to be the filename /// of the original upload. body: String, /// The original filename of the uploaded file. filename: String, /// Information about the file referred to in url. info: Option<FileInfo>, /// Metadata about the image referred ...
code_fim
hard
{ "lang": "rust", "repo": "DigitalChiller/glitch-in-the-matrix", "path": "/src/types.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|>#[fasync::run_singlethreaded] /// Simple program which effectively never returns. async fn main() { futures::future::pending::<()>().await; }<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/sys/component_manager/tests/events_v2/components/stub/component.rs // Copyright 2022 The Fuchsia Authors. All...
code_fim
easy
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/component_manager/tests/events_v2/components/stub/component.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/sys/component_manager/tests/events_v2/components/stub/component.rs // Copyright 2022 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. <|fim_suffix|>#[fasync::run_singleth...
code_fim
easy
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/component_manager/tests/events_v2/components/stub/component.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xin-operating-system/xinOS-RustBoilerplate path: /src/game.rs use crate::rgb888_to_rgb565; use crate::xinlib::{wait, exit_to_main}; use crate::xinlib::vesa::{draw_background, draw_str}; <|fim_suffix|> wait(5000); exit_to_main(); }<|fim_middle|>#[no_mangle] pub extern "C" fn yourGame_main...
code_fim
medium
{ "lang": "rust", "repo": "xin-operating-system/xinOS-RustBoilerplate", "path": "/src/game.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> wait(5000); exit_to_main(); }<|fim_prefix|>// repo: xin-operating-system/xinOS-RustBoilerplate path: /src/game.rs use crate::rgb888_to_rgb565; use crate::xinlib::{wait, exit_to_main}; use crate::xinlib::vesa::{draw_background, draw_str}; <|fim_middle|>#[no_mangle] pub extern "C" fn yourGame_main...
code_fim
medium
{ "lang": "rust", "repo": "xin-operating-system/xinOS-RustBoilerplate", "path": "/src/game.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mukeshsoni/xstate-viz-chrome-extension path: /parser_rust/src/parser/tokenizer.rs use regex::Regex; // How do i print my structs and enums? // There are 2 ways // 1. We can implement the Debug trait // 2. We can use the derive attribute. An attribute is used like in the format // below and is u...
code_fim
hard
{ "lang": "rust", "repo": "mukeshsoni/xstate-viz-chrome-extension", "path": "/parser_rust/src/parser/tokenizer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // How to split a string into lines? using split function. But it's not // that simple. `split` return an iterator and if we want the lines as // as vector or array, we have to use the collect method of the iterator // The syntax for collect gets weird when we want to tell it the type to ...
code_fim
hard
{ "lang": "rust", "repo": "mukeshsoni/xstate-viz-chrome-extension", "path": "/parser_rust/src/parser/tokenizer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> static INPUT: &str = "abc % some comment def -> lmn pasta -> noodles %more comment ast&* opq -> rst; ifyes uvw -> #abc.lastState nestedstate1 nestedstate2* tried -> that > andDoThis lastState % trying out transient state -> ast; ifyes -> lastState; ifno"; // ...
code_fim
hard
{ "lang": "rust", "repo": "mukeshsoni/xstate-viz-chrome-extension", "path": "/parser_rust/src/parser/tokenizer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tixel/developer-exercises path: /1.basic/2.elements/exercise/zomes/exercise/src/lib.rs use hdk3::prelude::*; mod tests; // Gym Exercise: http://holochain-gym.github.io/developers/beginner/elements/ <|fim_suffix|>// Returns the header timestamp from the element pub fn get_header_timestamp(_elem...
code_fim
medium
{ "lang": "rust", "repo": "tixel/developer-exercises", "path": "/1.basic/2.elements/exercise/zomes/exercise/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// Returns whether the header has been produced by the subconscious of holochain or if it was some hdk call pub fn is_header_subconscious(_header: Header) -> bool { unimplemented!() }<|fim_prefix|>// repo: tixel/developer-exercises path: /1.basic/2.elements/exercise/zomes/exercise/src/lib.rs use hdk3...
code_fim
medium
{ "lang": "rust", "repo": "tixel/developer-exercises", "path": "/1.basic/2.elements/exercise/zomes/exercise/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// Returns whether the element contains some entry or not pub fn contains_entry(_element: Element) -> bool { unimplemented!() } // Returns whether the header has been produced by the subconscious of holochain or if it was some hdk call pub fn is_header_subconscious(_header: Header) -> bool { unim...
code_fim
medium
{ "lang": "rust", "repo": "tixel/developer-exercises", "path": "/1.basic/2.elements/exercise/zomes/exercise/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn parse(&self, input: &[String]) -> Result<CLIOptions, getopts::Fail> { let matches = self.protocol.parse(input)?; Ok(CLIOptions { show_help: matches.opt_present("h"), #[cfg(unix)] foreground: matches.opt_present("f"), #[cfg(windows)] foreground: !cfg!(feature = "ui"), log_fil...
code_fim
hard
{ "lang": "rust", "repo": "agersant/polaris", "path": "/src/options.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: agersant/polaris path: /src/options.rs use simplelog::LevelFilter; use std::path::PathBuf; pub struct CLIOptions { pub show_help: bool, pub foreground: bool, pub log_file_path: Option<PathBuf>, #[cfg(unix)] pub pid_file_path: Option<PathBuf>, pub config_file_path: Option<PathBuf>, pub da...
code_fim
hard
{ "lang": "rust", "repo": "agersant/polaris", "path": "/src/options.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn get_options() -> getopts::Options { let mut options = getopts::Options::new(); options.optopt("c", "config", "set the configuration file", "FILE"); options.optopt("p", "port", "set polaris to run on a custom port", "PORT"); options.optopt("d", "database", "set the path to index database", "FILE"); ...
code_fim
hard
{ "lang": "rust", "repo": "agersant/polaris", "path": "/src/options.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aiifabbf/leetcode-memo path: /215.rust/src/main.rs /* .. default-role:: math 给一个乱序的array,找到第 `k` 大的数字 最简单的当然是排个序,直接定位到第 `k` 大的数字,复杂度是 `O(n \ln n)` 。 有更快的方法,叫quick select <https://en.wikipedia.org/wiki/Quickselect> ,是快速排序的修改版,运气好的话,可以在数列还没有完全排好的时候就直接得到第 `k` 大的数字。 回顾一下快速排序的过程,因为要找第 `k` 大的数字,那这...
code_fim
hard
{ "lang": "rust", "repo": "aiifabbf/leetcode-memo", "path": "/215.rust/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if k == left { // 所以如果运气好,基准数字的最终位置正好是k return pivot; // 那第k大的数字就是基准数字 } else if k < left { // 不巧,第k大的数字还在前面一半 return Self::kthLargest(&mut array[..left], k); // 那就继续找 } else { // 第k大的数字在后面一...
code_fim
hard
{ "lang": "rust", "repo": "aiifabbf/leetcode-memo", "path": "/215.rust/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tylerreisinger/sprite-atlas path: /src/options.rs use std::path; use std::u32; use clap::{self, Arg}; #[derive(Default, Debug)] pub struct InputOptions { pub directories: Vec<path::PathBuf>, pub max_width: u32, pub max_height: u32, } <|fim_suffix|> let directories = opts.values...
code_fim
hard
{ "lang": "rust", "repo": "tylerreisinger/sprite-atlas", "path": "/src/options.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let directories = opts.values_of("directories") .expect("One or more directories must be specified") .map(|s| path::PathBuf::from(s)) .collect::<Vec<_>>(); let max_width = opts.value_of("max_width") .unwrap() .parse::<u32>().expect("max_width must be a valid...
code_fim
hard
{ "lang": "rust", "repo": "tylerreisinger/sprite-atlas", "path": "/src/options.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Filesystem { pub fn entry<P: AsRef<path::Path>>(path: P) -> Result<Entry, io::Error> { fs::metadata(path).map(entry_from_metadata).or_else(entry_from_error) } }<|fim_prefix|>// repo: justinsacbibit/rit path: /src/lib/filesystem.rs use std::fmt; use std::fs; use std::io; use std::os::...
code_fim
hard
{ "lang": "rust", "repo": "justinsacbibit/rit", "path": "/src/lib/filesystem.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: justinsacbibit/rit path: /src/lib/filesystem.rs use std::fmt; use std::fs; use std::io; use std::os::unix::fs::PermissionsExt; use std::path; #[derive(Debug)] pub enum Entry { File, Executable, Directory, DoesNotExist, } impl fmt::Display for Entry { fn fmt(&self, f: &mut f...
code_fim
medium
{ "lang": "rust", "repo": "justinsacbibit/rit", "path": "/src/lib/filesystem.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_effect_shield() { let mut boss = Character::new(50, 5, 500); let mut player = Character::new(50, 0, 500); player.cast_spell(*get_all_spells().get(&SpellEnum::Shield).unwrap()); boss.attack(&mut player); assert_eq!(player.hitpoints, 49); }...
code_fim
hard
{ "lang": "rust", "repo": "jakubbaron/advent_of_code", "path": "/2015/day-22/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn apply_effects(&mut self, boss: &mut Character) { let mut to_keep: Vec<Spell> = Vec::new(); for effect in self.effects.iter_mut() { effect.turns -= 1; if effect.turns > 0 { println!("{}'s timer is now at {}", effect.name, effect.turns); ...
code_fim
hard
{ "lang": "rust", "repo": "jakubbaron/advent_of_code", "path": "/2015/day-22/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jakubbaron/advent_of_code path: /2015/day-22/src/lib.rs use std::collections::{HashMap, HashSet}; #[derive(Hash, PartialEq, Eq)] pub enum SpellEnum { MagicMissle, Drain, Shield, Poison, Recharge, } #[derive(Clone)] pub struct Character { pub hitpoints: i64, pub dama...
code_fim
hard
{ "lang": "rust", "repo": "jakubbaron/advent_of_code", "path": "/2015/day-22/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Context { pub(crate) fn try_new( data_path: PathBuf, file_name_prefix: String, initial_config: Config, initial_state: State, event_cb: Box<dyn ContextEventCallback + Send>, ) -> Result<Self> { let register_groups = create_register_group_contexts...
code_fim
hard
{ "lang": "rust", "repo": "slowtec/msr", "path": "/plugins/csv-register-recorder/src/internal/context.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn filter_records( &self, limit: NonZeroUsize, filter: RecordPreludeFilter, ) -> Result<Vec<StoredRegisterRecord>>; fn total_record_count(&self) -> usize; } #[allow(clippy::needless_pass_by_value)] fn create_register_group_contexts( data_path: &Path, file_nam...
code_fim
hard
{ "lang": "rust", "repo": "slowtec/msr", "path": "/plugins/csv-register-recorder/src/internal/context.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: slowtec/msr path: /plugins/csv-register-recorder/src/internal/context.rs ate { Inactive, Active, } #[derive(Debug, Clone)] pub struct Status { pub state: State, pub register_groups: Option<HashMap<RegisterGroupId, RegisterGroupStatus>>, } #[derive(Debug, Clone, Eq, PartialEq)] ...
code_fim
hard
{ "lang": "rust", "repo": "slowtec/msr", "path": "/plugins/csv-register-recorder/src/internal/context.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match fs::create_dir(&new_path) { Ok(()) => { println!("ok"); } Err(err) => { println!...
code_fim
hard
{ "lang": "rust", "repo": "psychoss/rust-example", "path": "/file_system/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: psychoss/rust-example path: /file_system/src/main.rs use std::path::Path; use std::fs::{self, DirEntry}; fn main() { let path = Path::new("/home/psycho/Downloads"); if fs::metadata(&path).unwrap().is_dir() { for entry in fs::read_dir(&path).unwrap() { let file = entr...
code_fim
hard
{ "lang": "rust", "repo": "psychoss/rust-example", "path": "/file_system/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: frankegoesdown/LeetCode-in-Go path: /Algorithms/0464.can-i-win/can-i-win.go package problem0464 // 影响成败的关键因素有两个 // 1. 还能选择的数字 // 2. 还需要累加的值 // 这两个又其实只是一个因素 -- 已经使用过的数,因为 // 1. 还能选择的数字 == 全部可选的数 - 已经使用过的数 // 2. 还需要累加的值 == desiredTotal - sum(已经使用过的数) // 题目想要求解的是 "已经使用过的数" == nil 时,能不能赢 // // 相同的 ...
code_fim
hard
{ "lang": "rust", "repo": "frankegoesdown/LeetCode-in-Go", "path": "/Algorithms/0464.can-i-win/can-i-win.go", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if isOpponentWin == false { // 对手输了 // 所以,是我赢了 // 请注意,下面的 usedBit 是删除了 i 的 // 此时的 dp[usedBit] = true 表示 // 我在面临 usedBit 这种状态下能赢,因为可以选择 i dp[usedBit] = true return true } } dp[usedBit] = false return false }<|fim_prefix|>// repo: frankegoesdown/LeetCode-in-Go path: /Algorithms/04...
code_fim
hard
{ "lang": "rust", "repo": "frankegoesdown/LeetCode-in-Go", "path": "/Algorithms/0464.can-i-win/can-i-win.go", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut buf = vec![]; loop { match stream.read_to_end(&mut buf) { Ok(_) => break, Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => { // do nothing } Err(e) => panic!("encountered IO error: {}", e), }; } p...
code_fim
medium
{ "lang": "rust", "repo": "tyleretchart/pi-widgets", "path": "/berry_base/src/communication.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tyleretchart/pi-widgets path: /berry_base/src/communication.rs use std::io::prelude::*; use std::io::{self, Read}; use std::net::TcpStream; pub fn connect_with_gui(address: &String, data: String) -> String { let mut stream = TcpStream::connect(address).expect("Couldn't connect to the server...
code_fim
hard
{ "lang": "rust", "repo": "tyleretchart/pi-widgets", "path": "/berry_base/src/communication.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: therockstorm/learning-rust path: /pvs/src/lib.rs extern crate quick_xml; use quick_xml::de; use serde::{Deserialize, Serialize}; use std::error::Error; use std::fs::File; use std::io::BufReader; use std::path::Path; use core::{self, ColorMaterial, Transform}; const DEFAULT_ORIENTATION: &str =...
code_fim
hard
{ "lang": "rust", "repo": "therockstorm/learning-rust", "path": "/pvs/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> components: &Vec<Component>, root_idx: usize, ) -> Result<Vec<SceneItem>, Box<dyn Error>> { let mut items = vec![]; add_items(components, &components[root_idx], "", None, &mut items)?; Ok(items) } fn add_items( components: &Vec<Component>, component: &Component, path_id: &...
code_fim
hard
{ "lang": "rust", "repo": "therockstorm/learning-rust", "path": "/pvs/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: infinityb/yscloud path: /boss/magnetite-common/src/torrent.rs use std::path::PathBuf; use std::borrow::Cow; use std::fmt; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; use serde::ser::SerializeMap; use crate::torrent_id::TorrentId; // -- #[derive(Serialize, Deserialize,...
code_fim
hard
{ "lang": "rust", "repo": "infinityb/yscloud", "path": "/boss/magnetite-common/src/torrent.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn serialize<S>(buf: &PathBuf, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { let mut seq = serializer.serialize_seq(Some(buf.components().count()))?; for co in buf.components() { match co { Component::Prefix(..) | Comp...
code_fim
hard
{ "lang": "rust", "repo": "infinityb/yscloud", "path": "/boss/magnetite-common/src/torrent.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod bt_pathbuf { use std::borrow::Cow; use std::fmt; use std::path::{Component, Path, PathBuf}; use serde::de::{self, Deserializer, SeqAccess, Visitor}; use serde::ser::{self, SerializeSeq, Serializer}; pub fn serialize<S>(buf: &PathBuf, serializer: S) -> Result<S::Ok, S::Error> ...
code_fim
hard
{ "lang": "rust", "repo": "infinityb/yscloud", "path": "/boss/magnetite-common/src/torrent.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eclight/RustLife path: /src/main.rs #![windows_subsystem = "windows"] mod world; mod color; mod cell_state; use sdl2::event::Event; use sdl2::rect::Rect; use sdl2::keyboard::Keycode; use world::{CellIndex, World}; const MODE_NORMAL: i32 = 0; const MODE_COLOR: i32 = 1; fn choose_driver() -> u...
code_fim
hard
{ "lang": "rust", "repo": "eclight/RustLife", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> const CELL_SIZE: u32 = 4; let mut events = ctx.event_pump().unwrap(); let mut timer = ctx.timer().unwrap(); let mut last_time = timer.ticks(); let mut world = World::new(200, 150); let mut draw_mode = 0; let back_color = sdl2::pixels::Color::RGB(0, 0, 0); world.fill_random...
code_fim
hard
{ "lang": "rust", "repo": "eclight/RustLife", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for col in 0..world.cols { for row in 0..world.rows { let state = world.get_state(CellIndex { row: row, col: col, }); if draw_mode == MODE_NORMAL { ...
code_fim
hard
{ "lang": "rust", "repo": "eclight/RustLife", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: juleskers/exercism.io-rust path: /template.rs // Follow the complete history of this file, including al<|fim_suffix|>tps://github.com/juleskers/exercism.io-rust fn foo() { }<|fim_middle|>l my painful learning // experiences and conversations with the compiler at my github diary "Learning Rust"...
code_fim
medium
{ "lang": "rust", "repo": "juleskers/exercism.io-rust", "path": "/template.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>tps://github.com/juleskers/exercism.io-rust fn foo() { }<|fim_prefix|>// repo: juleskers/exercism.io-rust path: /template.rs // Follow the complete history of this file, including al<|fim_middle|>l my painful learning // experiences and conversations with the compiler at my github diary "Learning Rust"...
code_fim
medium
{ "lang": "rust", "repo": "juleskers/exercism.io-rust", "path": "/template.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // DB Pool let pool = PgPoolOptions::new() .max_connections(5) .connect(&db_connection_url) .await?; // Adapters let order_persistence_adapter = OrderPersistenceAdapter::new(pool.clone()); let customer_persistence_adapter = CustomerPersistenceAdapter::new(pool....
code_fim
hard
{ "lang": "rust", "repo": "ozer/barista", "path": "/adapters/rest/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ozer/barista path: /adapters/rest/src/main.rs use anyhow::Result; use serde::{Deserialize, Serialize}; use tide::{Error, Request, Response, Server, StatusCode}; use crate::order_coffee_request::OrderCoffeeRequest; use barista_application::application::port::incoming::get_order_query::GetOrderQu...
code_fim
hard
{ "lang": "rust", "repo": "ozer/barista", "path": "/adapters/rest/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] pub struct User { /// A plain text displayable name for this user. #[serde(rename = "displayName", skip_serializing_if = "Option::is_none")] pub display_name: Option<String>, /// The email address of the user. This may not...
code_fim
medium
{ "lang": "rust", "repo": "caiges/google-drive-rust", "path": "/src/models/user.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: caiges/google-drive-rust path: /src/models/user.rs /* * Drive API * * Manages files in Drive including uploading, downloading, searching, detecting changes, and updating sharing permissions. * * The version of the OpenAPI document: v3 * * Generated by: https://openapi-generator.tech */ ...
code_fim
hard
{ "lang": "rust", "repo": "caiges/google-drive-rust", "path": "/src/models/user.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>elf.bits >> 14) & 0x01) != 0) } #[doc = "Bit 15 - Enable Polling Expiration"] #[inline(always)] pub fn enablepollingexp(&self) -> ENABLEPOLLINGEXP_R { ENABLEPOLLINGEXP_R::new(((self.bits >> 15) & 0x01) != 0) } #[doc = "Bits 16:23 - Poll Count"] #[inline(always)] pub...
code_fim
hard
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/qspi0/writecompletionctrl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pablo-mansanet-bluefruit/efm32gg11b path: /src/qspi0/writecompletionctrl.rs #[doc = "Reader of register WRITECOMPLETIONCTRL"] pub type R = crate::R<u32, super::WRITECOMPLETIONCTRL>; #[doc = "Writer for register WRITECOMPLETIONCTRL"] pub type W = crate::W<u32, super::WRITECOMPLETIONCTRL>; #[doc =...
code_fim
hard
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/qspi0/writecompletionctrl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Fail)] pub enum UiStylesError { #[fail(display = "{}", _0)] FileError(#[cause] RootFileError), #[fail(display = "Could not convert the FontCollection to a single Font.")] FontError, } impl From<RootFileError> for UiStylesError { fn from(value: RootFileError) -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "nausicaea/rootspace-rs", "path": "/engine/src/common/ui_styles.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Tooltip { pub fn new( font_group: FontGroup, text_shaders: ShaderGroup, rect_shaders: ShaderGroup, rect_textures: TextureGroup, ) -> Self { Tooltip { relative_position_offset: Vector2::new(-0.5, 0.5), text_width: 100, ...
code_fim
hard
{ "lang": "rust", "repo": "nausicaea/rootspace-rs", "path": "/engine/src/common/ui_styles.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nausicaea/rootspace-rs path: /engine/src/common/ui_styles.rs use nalgebra::Vector2; use common::file_manipulation::FileError as RootFileError; use common::resource_group::{FontGroup, ShaderGroup, TextureGroup}; use common::layout_group::MarginGroup; pub struct SpeechBubble { pub relative_po...
code_fim
hard
{ "lang": "rust", "repo": "nausicaea/rootspace-rs", "path": "/engine/src/common/ui_styles.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for k in 0..((j - i) / 2 + 1) { swap(&mut a, i + k, j - k); } } impl Iterator for Permutation { type Item = u64; fn next(&mut self) -> Option<u64> { let mut k = 0; let mut l = 0; for i in 0..(self.current.len() - 1) { if self.current[i] < self....
code_fim
medium
{ "lang": "rust", "repo": "madbence/rust-euler", "path": "/p043.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: madbence/rust-euler path: /p043.rs fn main() { let mut sum = 0; for n in permutations(vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) { if (n / 100_000_000 % 10 * 100 + n / 10_000_000 % 10 * 10 + n / 1_000_000 % 10) % 2 == 0 && (n / 10_000_000 % 10 * 100 + n / 1_000_000 % 10 * 10...
code_fim
hard
{ "lang": "rust", "repo": "madbence/rust-euler", "path": "/p043.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let path = Path::new("./src"); println!("Listing '{}'", path.display()); println!("==="); walk(path, &|d| println!(" {}", d.display()), true)?; println!(); let glob_pattern = "../**/*.rs"; println!("Listing by glob filter: {}", glob_pattern); println!("==="); walk_glo...
code_fim
hard
{ "lang": "rust", "repo": "PacktPublishing/Rust-Programming-Cookbook", "path": "/Chapter10/filesystem/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PacktPublishing/Rust-Programming-Cookbook path: /Chapter10/filesystem/src/main.rs use glob; use std::error::Error; use std::io; use std::path::{Path, PathBuf}; type GenericError = Box<dyn Error + Send + Sync + 'static>; fn walk(dir: &Path, cb: &dyn Fn(&PathBuf), recurse: bool) -> io::Result<()...
code_fim
hard
{ "lang": "rust", "repo": "PacktPublishing/Rust-Programming-Cookbook", "path": "/Chapter10/filesystem/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for entry in glob::glob(pattern)? { cb(&entry?); } Ok(()) } fn main() -> Result<(), GenericError> { let path = Path::new("./src"); println!("Listing '{}'", path.display()); println!("==="); walk(path, &|d| println!(" {}", d.display()), true)?; println!(); let...
code_fim
medium
{ "lang": "rust", "repo": "PacktPublishing/Rust-Programming-Cookbook", "path": "/Chapter10/filesystem/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let common = Common::arbitrary(g); let hdrbuilder = HeaderBuilderNew::new_raw( common.block_version, &common.block_content_hash, common.block_content_size, ) .set_parent(&common.block_parent_hash, common.chain_length) .set_date(co...
code_fim
hard
{ "lang": "rust", "repo": "input-output-hk/chain-libs", "path": "/chain-impl-mockchain/src/header/test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Common { block_version: Arbitrary::arbitrary(g), block_date: Arbitrary::arbitrary(g), block_content_size: Arbitrary::arbitrary(g), block_content_hash: Arbitrary::arbitrary(g), block_parent_hash: Arbitrary::arbitrary(g), chain_...
code_fim
hard
{ "lang": "rust", "repo": "input-output-hk/chain-libs", "path": "/chain-impl-mockchain/src/header/test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: input-output-hk/chain-libs path: /chain-impl-mockchain/src/header/test.rs use super::*; use crate::chaintypes::ChainLength; use crate::header::{BftProof, BftSignature, Common, GenesisPraosProof, KesSignature}; use crate::key::BftLeaderId; #[cfg(test)] use crate::testing::serialization::serializa...
code_fim
hard
{ "lang": "rust", "repo": "input-output-hk/chain-libs", "path": "/chain-impl-mockchain/src/header/test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PistonDevelopers/geometry path: /src/model.rs use range::Range; use wobj; use std::default::Default; use AddTo; use Vertex; use Object; use Geometry; /// A model consists of a list of object. /// The objects are stored separately, /// in an object buffer. pub struct Model(pub Vec<Range>); <|f...
code_fim
medium
{ "lang": "rust", "repo": "PistonDevelopers/geometry", "path": "/src/model.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Adds new model. pub fn add_range(&mut self, range: Range<AddTo<Model>>) { self.0.push(range.cast()) } }<|fim_prefix|>// repo: PistonDevelopers/geometry path: /src/model.rs use range::Range; use wobj; use std::default::Default; use AddTo; use Vertex; use Object; use Geometry; ///...
code_fim
hard
{ "lang": "rust", "repo": "PistonDevelopers/geometry", "path": "/src/model.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luqz/cita-common path: /jsonrpc-types/internals/src/lib.rs // Copyright Cryptape Technologies LLC. // // 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 // // http://www...
code_fim
hard
{ "lang": "rust", "repo": "luqz/cita-common", "path": "/jsonrpc-types/internals/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut attrs = quote!(); for attr in attrs_vec.iter() { attrs = quote!(#attrs #attr); } quote!(#attrs) } #[proc_macro] pub fn construct_params(input: proc_macro::TokenStream) -> proc_macro::TokenStream { let input: proc_macro2::TokenStream = input.into(); let output = { ...
code_fim
hard
{ "lang": "rust", "repo": "luqz/cita-common", "path": "/jsonrpc-types/internals/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> quote!( #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct #name (#types); impl #name { pub fn new(#params_with_types) -> #name { #name(#params) } } impl JsonRpcRequ...
code_fim
hard
{ "lang": "rust", "repo": "luqz/cita-common", "path": "/jsonrpc-types/internals/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Uri scheme + authority e.g. http://myaccount.table.core.windows.net/ pub fn get_uri_prefix(&self, service_type: &ServiceType) -> String { "https://".to_owned() + self.account() + match *service_type { ServiceType::Blob => SERVICE_SUFFIX_BLOB, ServiceType::Table ...
code_fim
hard
{ "lang": "rust", "repo": "MindFlavor/azure_storage_sdk", "path": "/src/client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MindFlavor/azure_storage_sdk path: /src/client.rs use hyper; use hyper_tls; use hyper::header::Headers; use hyper::Method; use super::rest_client::{perform_request, ServiceType}; use azure_core_sdk::errors::AzureError; use tokio_core::reactor::Handle; // Can be variant for different cloud env...
code_fim
hard
{ "lang": "rust", "repo": "MindFlavor/azure_storage_sdk", "path": "/src/client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/futures-rs path: /futures/tests/macro-tests/src/main.rs // Check that it works even if proc-macros are reexported. fn main() { use futures04::{executor::block_on, future}; // join! macro block_on(async { let _ = futures04::join!(async {}, async {}); let _ ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/futures-rs", "path": "/futures/tests/macro-tests/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut a = future::ready(()); let mut b = future::pending::<()>(); macro_reexport::select_biased! { _ = a => {}, _ = b => unreachable!(), }; let mut a = future::ready(()); let mut b = future::pending::<()>(); macro_reexport:...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/futures-rs", "path": "/futures/tests/macro-tests/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mojtab23/sodium_rust path: /src/cell_loop.rs use crate::impl_::cell_loop::CellLoop as CellLoopImpl; use crate::Cell; use crate::SodiumCtx; /// A forward reference for a [`Cell`] for creating dependency loops. /// /// Both the creation of a `CellLoop` and filling it with the /// referenced [`Cel...
code_fim
hard
{ "lang": "rust", "repo": "mojtab23/sodium_rust", "path": "/src/cell_loop.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> /// Resolve the loop to specify what this `CellLoop` was a forward /// reference to. /// /// This function must be invoked in the same transaction as the /// place where the `CellLoop` was created. This requires creating /// an explicit transaction, either with /// [`SodiumCtx:...
code_fim
hard
{ "lang": "rust", "repo": "mojtab23/sodium_rust", "path": "/src/cell_loop.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: psoc-rs/psoc6-pac path: /src/sar/intr_masked.rs #[doc = "Register `INTR_MASKED` reader"] pub struct R(crate::R<INTR_MASKED_SPEC>); impl core::ops::Deref for R { type Target = crate::R<INTR_MASKED_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 }...
code_fim
hard
{ "lang": "rust", "repo": "psoc-rs/psoc6-pac", "path": "/src/sar/intr_masked.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[doc = "Bit 2 - Logical and of corresponding request and mask bits."] #[inline(always)] pub fn fw_collision_masked(&self) -> FW_COLLISION_MASKED_R { FW_COLLISION_MASKED_R::new(((self.bits >> 2) & 1) != 0) } #[doc = "Bit 3 - Logical and of corresponding request and mask bi...
code_fim
hard
{ "lang": "rust", "repo": "psoc-rs/psoc6-pac", "path": "/src/sar/intr_masked.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>m, Err(_) => continue, }; match guess.cmp(&secret_number) { Ordering::Less => println!("Too small!"), Ordering::Greater => println!("Too big!"), Ordering::Equal => { println!("You win!"); break; }, ...
code_fim
hard
{ "lang": "rust", "repo": "JackMordaunt/learning_rust", "path": "/guessing_game/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JackMordaunt/learning_rust path: /guessing_game/src/main.rs extern crate rand; use std::env::args; use std::io; use std::cmp::Ordering; use rand::Rng; fn main() { let mut lower: u32 = 1; let mut upper: u32 = 100; for arg in args() { let bounds: Vec<&str> = arg.split("-").co...
code_fim
hard
{ "lang": "rust", "repo": "JackMordaunt/learning_rust", "path": "/guessing_game/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: OhBonsai/rust-leetcode path: /double-pointer/src/q977.rs struct Solution (); impl Solution { pub fn sorted_squares(nums: Vec<i32>) -> Vec<i32> { let n = nums.len(); if n == 0 { return vec![] } let mut p1 = 0; ...
code_fim
hard
{ "lang": "rust", "repo": "OhBonsai/rust-leetcode", "path": "/double-pointer/src/q977.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for _ in 0..n { if nums[p1] < 0 && nums[p2] >= 0 { break } p1 = p1 + 1; p2 = p2 + 1; } loop { let l = nums[p1] * nums[p1]; let r = nums[p2] * nums[p2]; if l >= r { ...
code_fim
hard
{ "lang": "rust", "repo": "OhBonsai/rust-leetcode", "path": "/double-pointer/src/q977.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let field = CanvasBuilder::new(WidgetBuilder::new() .with_name(ScrollBar::PART_CANVAS) .on_column(match orientation { Orientation::Horizontal => 1, Orientation::Vertical => 0 }) .on_row(match orientation { ...
code_fim
hard
{ "lang": "rust", "repo": "dmvoiper/rg3d", "path": "/src/gui/scroll_bar.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn with_max(mut self, max: f32) -> Self { self.max = Some(max); self } pub fn with_value(mut self, value: f32) -> Self { self.value = Some(value); self } pub fn with_orientation(mut self, orientation: Orientation) -> Self { self.orientation...
code_fim
hard
{ "lang": "rust", "repo": "dmvoiper/rg3d", "path": "/src/gui/scroll_bar.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dmvoiper/rg3d path: /src/gui/scroll_bar.rs use crate::gui::{ border::BorderBuilder, canvas::CanvasBuilder, event::UIEventKind, button::ButtonBuilder, node::UINode, UserInterface, maxf, Thickness, Layout, grid::{GridBuilder, Column, Row}, event::UIEvent...
code_fim
hard
{ "lang": "rust", "repo": "dmvoiper/rg3d", "path": "/src/gui/scroll_bar.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /cranelift/codegen/src/isa/riscv64/inst/encode.rs //! Contains the RISC-V instruction encoding logic. //! //! These formats are specified in the RISC-V specification in section 2.2. //! See: https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf //! //! ...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/cranelift/codegen/src/isa/riscv64/inst/encode.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> let mut bits = 0; bits |= unsigned_field_width(opcode, 7); bits |= reg_to_gpr_num(vd) << 7; bits |= width << 12; bits |= reg_to_gpr_num(rs1) << 15; bits |= unsigned_field_width(lumop, 5) << 20; bits |= masking.encode() << 25; bits |= unsigned_field_width(mop, 2) << 26; ...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/cranelift/codegen/src/isa/riscv64/inst/encode.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>/// Request a connection to the nameserver-managed `name`. pub fn connect(name: &str) -> Option<crate::CID> { let mut request = ConnectRequest::new(name)?; let ns_cid = nameserver(); let memory_range = unsafe { crate::MemoryRange::new( &mut request as *mut ConnectRequest as...
code_fim
hard
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/xous-rs/src/services/nameserver.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: betrusted-io/xous-core path: /xous-rs/src/services/nameserver.rs use core::sync::atomic::{AtomicU32, Ordering}; // By making this repr(C), the layout of this struct becomes well-defined // and no longer shifts around. // By marking it as `align(4096) we define that it will be page-aligned, // m...
code_fim
hard
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/xous-rs/src/services/nameserver.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ConnectRequest { pub fn new(name: &str) -> Option<Self> { let mut cr: ConnectRequest = Default::default(); let name_bytes = name.as_bytes(); // Ensure the bytes won't blow out the buffer if name_bytes.len() > 64 { return None; } // Cop...
code_fim
hard
{ "lang": "rust", "repo": "betrusted-io/xous-core", "path": "/xous-rs/src/services/nameserver.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let nbf_opt = claims.get(NOT_BEFORE_CLAIM); match (nbf_strictness, nbf_opt) { (CheckStrictness::Ignored, _) | (CheckStrictness::Optional, None) => {} (CheckStrictness::Required, None) => { return Err(JwtError::...
code_fim
hard
{ "lang": "rust", "repo": "ionut-arm/picky-rs", "path": "/picky/src/jose/jwt.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ionut-arm/picky-rs path: /picky/src/jose/jwt.rs d validator: {}", description))] InvalidValidator { description: &'static str }, } impl From<rsa::errors::Error> for JwtError { fn from(e: rsa::errors::Error) -> Self { Self::Rsa { context: e.to_string() } } } impl From<serde_...
code_fim
hard
{ "lang": "rust", "repo": "ionut-arm/picky-rs", "path": "/picky/src/jose/jwt.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }