text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: hawkw/linkerd2-proxy path: /linkerd/tracing/src/lib.rs #![deny(warnings, rust_2018_idioms)] mod level; mod tasks; mod uptime; use self::uptime::Uptime; use linkerd2_error::Error; use std::{env, str}; use tokio_trace::tasks::TasksLayer; use tracing::Dispatch; use tracing_subscriber::{ fmt::...
code_fim
hard
{ "lang": "rust", "repo": "hawkw/linkerd2-proxy", "path": "/linkerd/tracing/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// === impl Handle === impl Handle { /// Serve requests that controls the log level. The request is expected to be either a GET or PUT /// request. PUT requests must have a body that describes the new log level. pub async fn serve_level( &self, req: http::Request<hyper::Body>,...
code_fim
hard
{ "lang": "rust", "repo": "hawkw/linkerd2-proxy", "path": "/linkerd/tracing/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match self { Self::Volume { current } => { set_volume(*current); config.volume = *current; }, } } } impl GameState for SettingsState { fn name(&self) -> &'static str { "Settings" } fn tick(&mut self, mut data: TickData) ...
code_fim
hard
{ "lang": "rust", "repo": "yancouto/functional", "path": "/src/gamestates/settings.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yancouto/functional path: /src/gamestates/settings.rs use super::base::*; use crate::{ audio::set_volume, prelude::*, save_system::{edit_and_save, load_common, CommonConfig}, utils::vec_with_cursor::VecWithCursor }; pub struct SettingsState { items: VecWithCursor<SettingsItem>, } impl ...
code_fim
hard
{ "lang": "rust", "repo": "yancouto/functional", "path": "/src/gamestates/settings.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> match self { Self::Volume { current } => { let prev = *current; match data.pressed_key { Some(Key::Left) => *current = (*current).max(1) - 1, Some(Key::Right) => *current = (*current).min(9) + 1, ...
code_fim
hard
{ "lang": "rust", "repo": "yancouto/functional", "path": "/src/gamestates/settings.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: categulario/tareog path: /src/main.rs use std::io::BufRead; const SIZE:usize = 10; fn add(arr: &mut [i32], pos: i32, amount: i32) { if pos > SIZE as i32 { return; } arr[pos as usize] += amount; add(arr, pos + (pos & -pos), amount); } fn sum(arr: &[i32], goal: i32) ->...
code_fim
medium
{ "lang": "rust", "repo": "categulario/tareog", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn query(arr: &[i32], from: i32, to: i32) -> i32 { return sum(arr, to) - sum(arr, from); } fn main() { let stdin = std::io::stdin(); let numcases:i32 = stdin.lock().lines().next().unwrap().unwrap().parse().unwrap(); let mut arr = [0; SIZE+1]; for _i in 0..numcases { let case:...
code_fim
medium
{ "lang": "rust", "repo": "categulario/tareog", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mmun/leetcode path: /src/220.contains-duplicate-iii.rs /* * @lc app=leetcode id=220 lang=rust * * [220] Contains Duplicate III */ // @lc code=start use std::collections::BTreeSet; impl Solution { pub fn contains_nearby_almost_duplicate(nums: Vec<i32>, k: i32, t: i32) -> bool { ...
code_fim
medium
{ "lang": "rust", "repo": "mmun/leetcode", "path": "/src/220.contains-duplicate-iii.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if i >= k { set.remove(&(nums[i - k])); } } return false; } } // @lc code=end<|fim_prefix|>// repo: mmun/leetcode path: /src/220.contains-duplicate-iii.rs /* * @lc app=leetcode id=220 lang=rust * * [220] Contains Duplicate III */ <|fim_mi...
code_fim
hard
{ "lang": "rust", "repo": "mmun/leetcode", "path": "/src/220.contains-duplicate-iii.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexheretic/ktx path: /src/header.rs use byteorder::{BigEndian, ByteOrder, LittleEndian}; pub(crate) const KTX1_IDENTIFIER: [u8; 12] = [ 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A, ]; /// KTX texture storage format parameters. /// /// See the [specification](htt...
code_fim
hard
{ "lang": "rust", "repo": "alexheretic/ktx", "path": "/src/header.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.as_ref().big_endian } #[inline] fn gl_type(&self) -> u32 { self.as_ref().gl_type } #[inline] fn gl_type_size(&self) -> u32 { self.as_ref().gl_type_size } #[inline] fn gl_format(&self) -> u32 { self.as_ref().gl_format } #[inli...
code_fim
hard
{ "lang": "rust", "repo": "alexheretic/ktx", "path": "/src/header.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.as_ref().gl_type } #[inline] fn gl_type_size(&self) -> u32 { self.as_ref().gl_type_size } #[inline] fn gl_format(&self) -> u32 { self.as_ref().gl_format } #[inline] fn gl_internal_format(&self) -> u32 { self.as_ref().gl_internal_form...
code_fim
hard
{ "lang": "rust", "repo": "alexheretic/ktx", "path": "/src/header.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // WOO Let's do some sketchy transformations~ let mut macros = <Punctuated<Ident, Token![,]>>::new(); for item in &mut input.items { match item { Item::Fn(func) => { // Check for the `proc_macro` attribute, and remove it. let old_len = func.a...
code_fim
hard
{ "lang": "rust", "repo": "mystor/ctrs", "path": "/wasm/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut input = syn::parse2::<CtrsInput>(input).unwrap(); // WOO Let's do some sketchy transformations~ let mut macros = <Punctuated<Ident, Token![,]>>::new(); for item in &mut input.items { match item { Item::Fn(func) => { // Check for the `proc_macro`...
code_fim
hard
{ "lang": "rust", "repo": "mystor/ctrs", "path": "/wasm/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mystor/ctrs path: /wasm/src/lib.rs //! Internal implementation crate for `ctrs` #![deny(warnings)] use proc_macro2::{TokenStream, TokenTree}; use syn::parse::{Parse, ParseStream}; use syn::punctuated::Punctuated; use syn::*; use quote::quote; struct BuildResult { _name: Ident, wasm: T...
code_fim
hard
{ "lang": "rust", "repo": "mystor/ctrs", "path": "/wasm/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let seed = sub_matches .value_of("seed") .unwrap_or("") .parse::<u64>() .unwrap_or(0); let pattern = CompositePattern::from(pattern.as_slice()); let cmd_config = Config { format: OutputFormat::from(format.unwrap()), ...
code_fim
hard
{ "lang": "rust", "repo": "zfzackfrost/string_studio", "path": "/src/cmdargs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zfzackfrost/string_studio path: /src/cmdargs.rs use clap::{App, Arg, SubCommand}; use std::str::FromStr; use crate::config::*; use crate::xform::Xform; use std::fs; use std::path::Path; #[derive(PartialEq)] pub enum AppAction { Root, Generate, DumpConfig, } fn require_parsed_str<...
code_fim
hard
{ "lang": "rust", "repo": "zfzackfrost/string_studio", "path": "/src/cmdargs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: angular-rust/opengles-tutorial path: /c07_in_practice/src/mesh.rs use cgmath::prelude::*; use cgmath::{Vector2, Vector3}; use dx::gles::{core30::gl, enums::*}; use std::mem::size_of; use super::shader::Shader; // NOTE: without repr(C) the compiler may reorder the fields or use different paddin...
code_fim
hard
{ "lang": "rust", "repo": "angular-rust/opengles-tutorial", "path": "/c07_in_practice/src/mesh.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// render the mesh pub fn draw(&self, shader: &Shader) { // bind appropriate textures let mut diffuse_nr = 0; let mut specular_nr = 0; let mut normal_nr = 0; let mut height_nr = 0; for (i, texture) in self.textures.iter().enumerate() { g...
code_fim
hard
{ "lang": "rust", "repo": "angular-rust/opengles-tutorial", "path": "/c07_in_practice/src/mesh.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amerelo/Computor_v1 path: /src/degree2_module/solver.rs use list_module::module::Module; use list_module::module::Elem; use std::process; pub struct Solver { } impl Solver { pub fn get_value(list: &Vec<Elem>, find: f32) -> f32 { for elem in list { if elem.power == find { return el...
code_fim
hard
{ "lang": "rust", "repo": "amerelo/Computor_v1", "path": "/src/degree2_module/solver.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let delta = b.powf(2.0) - 4.0 * a * c; if delta > 0.0 { println!("Discriminant is strictly positive, 2 solutions are :"); println!("sol 1 = {}", (-b - delta.sqrt()) / (2.0 * a)); println!("sol 2 = {}", (-b + delta.sqrt()) / (2.0 * a)); } else if delta == 0.0{ println!("Discriminant is...
code_fim
hard
{ "lang": "rust", "repo": "amerelo/Computor_v1", "path": "/src/degree2_module/solver.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sstr = sstrs.join(" "); let opt = opts.join(" "); let file_pos_cmd = format!(r#"rg --with-filename --color=always -n {} "{}" {} | fzf --ansi -e --tac -0 -1 --cycle --min-height=20 -d ':' --preview="echo '\033[1;32m {{1}}\033[0m'; fspreview {{}} {}" --preview-window=right:60% | gawk -F':' ...
code_fim
hard
{ "lang": "rust", "repo": "wang-borong/bintools-rust", "path": "/src/fs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wang-borong/bintools-rust path: /src/fs.rs use std::process::exit; use std::path::Path; use term_size; use crate::shell; use crate::utils; pub fn run(args: &Vec<String>) { if args.len() < 1 { eprintln!("Usage: fs [options] <search patterns>"); exit(1); } if !utils:...
code_fim
medium
{ "lang": "rust", "repo": "wang-borong/bintools-rust", "path": "/src/fs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .override_usage(format_usage(USAGE)) .infer_long_args(true) .disable_help_flag(true) .arg(Arg::new(options::NUMBER).action(ArgAction::Append)) ...
code_fim
hard
{ "lang": "rust", "repo": "uutils/coreutils", "path": "/src/uu/factor/src/cli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uutils/coreutils path: /src/uu/factor/src/cli.rs // This file is part of the uutils coreutils package. // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. use std::error::Error; use std::fmt::Write as FmtWrite; use st...
code_fim
hard
{ "lang": "rust", "repo": "uutils/coreutils", "path": "/src/uu/factor/src/cli.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(values) = matches.get_many::<String>(options::NUMBER) { for number in values { if let Err(e) = print_factors_str(number, &mut w, &mut factors_buffer, print_exponents) { show_warning!("{}: {}", number.maybe_quote(), e); } }...
code_fim
hard
{ "lang": "rust", "repo": "uutils/coreutils", "path": "/src/uu/factor/src/cli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: growingspaghetti/project-euler path: /rust/src/m28.rs //! ```txt //! ryoji@ubuntu:/media/dev/project-euler$ cargo bench --bench bench_main -- sum_of_the_numbers_on_the_diagonals_in_a_1001_by_1001 --verbose //! Compiling project-euler v0.1.0 (/media/dev/project-euler) //! //! Finished benc...
code_fim
hard
{ "lang": "rust", "repo": "growingspaghetti/project-euler", "path": "/rust/src/m28.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: /// /// 21 22 23 24 25 /// 20 7 8 9 10 /// 19 6 1 2 11 /// 18 5 4 3 12 /// 17 16 15 14 13 /// /// It can be verified that the sum of the numbers on the diagonals is 101. /// /// W...
code_fim
hard
{ "lang": "rust", "repo": "growingspaghetti/project-euler", "path": "/rust/src/m28.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pop-os/apt-sources-lists path: /examples/list.rs extern crate apt_sources_lists; use apt_sources_lists::*; pub fn main() { let list = SourcesLists::scan().unwrap(); for file in list.iter<|fim_suffix|>Line::Entry(ref entry) = *entry { println!(" Dist paths:"); ...
code_fim
hard
{ "lang": "rust", "repo": "pop-os/apt-sources-lists", "path": "/examples/list.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!(" {}", dist); } println!(" Pool path: {}", entry.pool_path()); } } } }<|fim_prefix|>// repo: pop-os/apt-sources-lists path: /examples/list.rs extern crate apt_sources_lists; use apt_sources_lists::*; pub fn main() { let l...
code_fim
hard
{ "lang": "rust", "repo": "pop-os/apt-sources-lists", "path": "/examples/list.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let print_usage = |msg| println!("{}\nUsage: new point {{x, y, color}}|rect {{x, y, width, height, color}} ", msg); let parse_color = |command: &mut std::str::SplitWhitespace| match command.next() { Some(color) => match color { "white" => {Some(Color::White)}, "red"...
code_fim
hard
{ "lang": "rust", "repo": "jajo-11/rustepdpi", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jajo-11/rustepdpi path: /src/lib.rs use std::io; pub mod bcm2835; pub mod epd; use epd::doodle; use epd::doodle::Color; pub fn interactive() { epd::epd_init(); let mut buff = epd::Frame::new(); println!("Welcome to doodle interactive!"); loop { let mut command = String...
code_fim
hard
{ "lang": "rust", "repo": "jajo-11/rustepdpi", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// metric name. #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "SCREAMING_SNAKE_CASE")] pub enum Name { /// Unspecified MetricName. MetricNameUnspecified, /// CPU usage. CpuUsage, /// GPU duty cycle. GpuDutyCycle, }<|fim_prefix|>// repo: lquerel/gcp-ml-client path: /src/model/google...
code_fim
hard
{ "lang": "rust", "repo": "lquerel/gcp-ml-client", "path": "/src/model/google_cloud_ml_v1_metric_spec.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lquerel/gcp-ml-client path: /src/model/google_cloud_ml_v1_metric_spec.rs //! MetricSpec contains the specifications to use to calculate the desired nodes count when autoscaling is enabled. <|fim_suffix|>/// metric name. #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "SCREAMING_SN...
code_fim
hard
{ "lang": "rust", "repo": "lquerel/gcp-ml-client", "path": "/src/model/google_cloud_ml_v1_metric_spec.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m-ou-se/pyo3 path: /examples/pyo3-benchmarks/src/lib.rs use pyo3::prelude::*; use pyo3::types::{PyDict, PyTuple}; use pyo3::wrap_pyfunction; #[pyfunction(args = "*", kwargs = "**")] fn args_and_kwargs<'a>( args: &'a PyTuple, kwargs: Option<&'a PyDict>, ) -> (&'a PyTuple, Option<&'a PyDi...
code_fim
hard
{ "lang": "rust", "repo": "m-ou-se/pyo3", "path": "/examples/pyo3-benchmarks/src/lib.rs", "mode": "psm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_suffix|> m.add_function(wrap_pyfunction!(args_and_kwargs, m)?)?; m.add_function(wrap_pyfunction!(mixed_args, m)?)?; m.add_function(wrap_pyfunction!(no_args, m)?)?; Ok(()) }<|fim_prefix|>// repo: m-ou-se/pyo3 path: /examples/pyo3-benchmarks/src/lib.rs use pyo3::prelude::*; use pyo3::types::{PyDict,...
code_fim
medium
{ "lang": "rust", "repo": "m-ou-se/pyo3", "path": "/examples/pyo3-benchmarks/src/lib.rs", "mode": "spm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { let context = ::redisConnect(c_str!("127.0.0.1"), 6379); assert!(!context.is_null()); assert!((*context).err == ::REDIS_OK); ::redisFree(context); } } }<|fim_prefix|>// repo: wangkang/hiredis-sys path: /src/lib.rs //! Bindings t...
code_fim
medium
{ "lang": "rust", "repo": "wangkang/hiredis-sys", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wangkang/hiredis-sys path: /src/lib.rs //! Bindings to [Hiredis][1]. //! //! [1]: https://github.com/redis/hiredis <|fim_suffix|> #[test] fn connect() { unsafe { let context = ::redisConnect(c_str!("127.0.0.1"), 6379); assert!(!context.is_null()); ...
code_fim
hard
{ "lang": "rust", "repo": "wangkang/hiredis-sys", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oro13/holo-rea path: /lib/rea_fulfillment/defs/src/lib.rs /** * Holo-REA fulfillment zome entry type definitions * * For use in the standard Holo-REA fulfillment zome, * or in zomes wishing to embed additional attributes & logic alongside the * standard `Fulfillment` data model. * * @pack...
code_fim
hard
{ "lang": "rust", "repo": "oro13/holo-rea", "path": "/lib/rea_fulfillment/defs/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> validation: | _validation_data: hdk::LinkValidationData| { Ok(()) } ) ] ) } /// Used on the upstream side of the link to build reciprocal query indexes /// :WARNING: incompatible with `base_entry_def`- do not use both in the same...
code_fim
hard
{ "lang": "rust", "repo": "oro13/holo-rea", "path": "/lib/rea_fulfillment/defs/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lj-211/leetcode path: /solutions/0054.rs /* * 给定一个包含 m x n 个元素的矩阵(m 行, n 列),请按照顺时针螺旋顺序,返回矩阵中的所有元素。 * * 示例 1: * * 输入: * [ * [ 1, 2, 3 ], * [ 4, 5, 6 ], * [ 7, 8, 9 ] * ] * 输出: [1,2,3,6,9,8,7,4,5] * 示例 2: * * 输入: * [ * [1, 2, 3, 4], * [5, 6, 7, 8], * [9,10,11,12] * ] *...
code_fim
hard
{ "lang": "rust", "repo": "lj-211/leetcode", "path": "/solutions/0054.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> spiral_order_vec } } fn main() { println!("0054: "); //let input = vec![vec![1, 2, 3], vec![4, 5, 6], vec![7, 8, 9]]; let input = vec![vec![1, 2], vec![4, 5], vec![7, 8]]; //let input = vec![vec![1], vec![4], vec![7]]; //let input = vec![vec![1, 2], vec![3, 4]]; let o...
code_fim
hard
{ "lang": "rust", "repo": "lj-211/leetcode", "path": "/solutions/0054.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for (_, line) in file.lines().enumerate() { let l = line.unwrap(); for (idx, c) in l.chars().enumerate() { if c == '(' { floor += 1; } else if c == ')' { floor -= 1; if floor < 0 && first_negative == 0 { ...
code_fim
medium
{ "lang": "rust", "repo": "pubkraal/Advent", "path": "/2015/advent/src/day01.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pubkraal/Advent path: /2015/advent/src/day01.rs use std::fs::File; use std::io::{BufRead, BufReader}; pub fn run() { let f = File::open("../input/01.txt").unwrap(); let file = BufReader::new(&f); <|fim_suffix|> for (_, line) in file.lines().enumerate() { let l = line.unwrap(...
code_fim
medium
{ "lang": "rust", "repo": "pubkraal/Advent", "path": "/2015/advent/src/day01.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if sand.x == min_x { left_h = sand.y; } if sand.x + 1 == max_x { right_h = sand.y; } // Remove this block from out path path.pop(); } // If we break early, there's a trail of sand to render! while let Some(s) = path.pop...
code_fim
hard
{ "lang": "rust", "repo": "Chris--B/advent-of-code", "path": "/2022/src/day14.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Chris--B/advent-of-code path: /2022/src/day14.rs use crate::prelude::*; const BLOCK_AIR: u8 = 0; const BLOCK_SAND: u8 = 1; const BLOCK_ROCK: u8 = 2; const BLOCK_SPAWN: u8 = 3; const BLOCK_FALLING_SAND: u8 = 4; const fn color(x: u32) -> image::Rgb<u8> { let [b, g, r, _a] = x.to_le_bytes(); ...
code_fim
hard
{ "lang": "rust", "repo": "Chris--B/advent-of-code", "path": "/2022/src/day14.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn walk_declaration<V: Visitor>(visitor: &mut V, decl: &Declaration) -> V::Output { match decl { &Declaration::Function(ref func) => visitor.visit_function(func), &Declaration::Variable(ref variables) => { for var in variables { ...
code_fim
hard
{ "lang": "rust", "repo": "alexmsmartins/rjs", "path": "/src/librjs_syntax/src/visitor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexmsmartins/rjs path: /src/librjs_syntax/src/visitor.rs self, expr: &SpannedExpression) -> Self::Output { walk_throw_statement(self, expr) } fn visit_try_statement(&mut self, body: &SpannedStatement, catch: Option<&CatchCla...
code_fim
hard
{ "lang": "rust", "repo": "alexmsmartins/rjs", "path": "/src/librjs_syntax/src/visitor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexmsmartins/rjs path: /src/librjs_syntax/src/visitor.rs } fn visit_empty_statement(&mut self) -> Self::Output { // nothing Default::default() } fn visit_debugger_statement(&mut self) -> Self::Output { // nothing Default::default() } fn vi...
code_fim
hard
{ "lang": "rust", "repo": "alexmsmartins/rjs", "path": "/src/librjs_syntax/src/visitor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: XOSplicer/rust_crypto_challenge path: /src/main.rs mod core; use core::*; fn main() { let hex = Hex::from_string("49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d").unwrap(); //println!("{:?}", hex); println!("{:?}", hex.to_string()); let b64r...
code_fim
medium
{ "lang": "rust", "repo": "XOSplicer/rust_crypto_challenge", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>intln!("{:?}", b64ref.to_string()); let b64 = hex.to_base64(); //println!("{:?}", b64); println!("{:?}", b64.to_string()); }<|fim_prefix|>// repo: XOSplicer/rust_crypto_challenge path: /src/main.rs mod core; use core::*; fn main() { let hex = Hex::from_string("49276d206b696c6c696e6720796f75722062726...
code_fim
medium
{ "lang": "rust", "repo": "XOSplicer/rust_crypto_challenge", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pfernie/cookie_store path: /src/utils.rs use std::net::{Ipv4Addr, Ipv6Addr}; use url::Url; use url::{Host, ParseError as UrlError}; pub trait IntoUrl { fn into_url(self) -> Result<Url, UrlError>; } impl IntoUrl for Url { fn into_url(self) -> Result<Url, UrlError> { Ok(self) ...
code_fim
hard
{ "lang": "rust", "repo": "pfernie/cookie_store", "path": "/src/utils.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> if !(self.resources_loaded) { self.resources_loaded = true; let ref mut tiles_image = open(map::TILES_FILENAME).unwrap(); let tz = map::TILE_SIZE; let width = tiles_image.dimensions().0 / tz; let height = tiles_image.dimensions().1 / tz; ...
code_fim
hard
{ "lang": "rust", "repo": "sebferrer/isuucc", "path": "/src/renderer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sebferrer/isuucc path: /src/renderer.rs use map; use game_state; use graphics::*; use image::{open, GenericImage, imageops}; use opengl_graphics::{GlGraphics, Texture, TextureSettings}; use piston::input::*; use std::collections::HashMap; use std::path::Path; use std::string::String; pub struc...
code_fim
hard
{ "lang": "rust", "repo": "sebferrer/isuucc", "path": "/src/renderer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: helloooooo/prac-algo path: /atcoder/resolve/src/abc070c.rs fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } <|fim_suffix|> let n = read::<i64>(); let mut v = vec![]; for _ in 0..n{ ...
code_fim
hard
{ "lang": "rust", "repo": "helloooooo/prac-algo", "path": "/atcoder/resolve/src/abc070c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: async-rs/async-std path: /src/option/mod.rs //! The Rust core optional value type //! //! This module provides the `Option<T>` type for returning and //! propagating optional values. mod from_stream; <|fim_suffix|>cfg_unstable! { mod product; mod sum; }<|fim_middle|>#[doc(inline)] pub ...
code_fim
easy
{ "lang": "rust", "repo": "async-rs/async-std", "path": "/src/option/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>cfg_unstable! { mod product; mod sum; }<|fim_prefix|>// repo: async-rs/async-std path: /src/option/mod.rs //! The Rust core optional value type //! //! This module provides the `Option<T>` type for returning and //! propagating optional values. <|fim_middle|>mod from_stream; #[doc(inline)] pub ...
code_fim
medium
{ "lang": "rust", "repo": "async-rs/async-std", "path": "/src/option/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ew(((self.bits >> 11) & 0x01) != 0) } #[doc = "Bit 10 - Receive only"] #[inline(always)] pub fn rxonly(&self) -> RXONLY_R { RXONLY_R::new(((self.bits >> 10) & 0x01) != 0) } #[doc = "Bit 9 - Software slave management"] #[inline(always)] pub fn ssm(&self) -> SSM_R { ...
code_fim
hard
{ "lang": "rust", "repo": "mcscholtz/stm32f407", "path": "/src/spi1/cr1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mcscholtz/stm32f407 path: /src/spi1/cr1.rs #[doc = "Reader of register CR1"] pub type R = crate::R<u32, super::CR1>; #[doc = "Writer for register CR1"] pub type W = crate::W<u32, super::CR1>; #[doc = "Register CR1 `reset()`'s with value 0"] impl crate::ResetValue for super::CR1 { type Type =...
code_fim
hard
{ "lang": "rust", "repo": "mcscholtz/stm32f407", "path": "/src/spi1/cr1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Get tags videos watched by the user // let tags_result: QueryResult<Vec<Tag>> = videos .select( sql::<Array<Record<(Integer, VarChar)>>>("array_remove(array_agg(distinct tags), null) as tags") ) .inner_join(video_plays) .inner_join(videos_tags.on(crat...
code_fim
hard
{ "lang": "rust", "repo": "theocrowley24/Cinema-Backend", "path": "/src/helpers/recommender.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return if let Ok(tags_result) = tags_result { // This is needed as Rust Diesel dose not support HAVING clauses let tags_ids: Vec<i32> = tags_result.iter().map(|tag| tag.id).collect(); let result: Vec<VideoWithUser> = result.into_iter().filter(|video| { for tag in vi...
code_fim
hard
{ "lang": "rust", "repo": "theocrowley24/Cinema-Backend", "path": "/src/helpers/recommender.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: theocrowley24/Cinema-Backend path: /src/helpers/recommender.rs use crate::establish_connection; use crate::schema::videos::dsl::{videos, id, status}; use diesel::{QueryDsl, ExpressionMethods, JoinOnDsl, BoolExpressionMethods, QueryResult}; use diesel::dsl::{sql, exists}; use diesel::pg::types::s...
code_fim
hard
{ "lang": "rust", "repo": "theocrowley24/Cinema-Backend", "path": "/src/helpers/recommender.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if !self.has_position(p + Vector2D::new(0, 1)) { res.push(GridSegment( p + Vector2D::new(0, 1), p + Vector2D::new(0, 1) + Vector2D::new(1, 0), GridSegmentType::Perimeter, )); } } ...
code_fim
hard
{ "lang": "rust", "repo": "mvr/abyme", "path": "/src/polyomino.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mvr/abyme path: /src/polyomino.rs extern crate euclid; use euclid::{Point2D, Rect, Size2D, Vector2D}; use rug::ops::DivRounding; use defs::*; #[derive(Debug, Clone, Hash, Eq, PartialEq)] pub struct Polyomino { pub squares: Vec<Point2D<i32>>, } #[derive(Debug, Clone, Copy, Hash, Eq, Parti...
code_fim
hard
{ "lang": "rust", "repo": "mvr/abyme", "path": "/src/polyomino.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rustwasm/wasm-bindgen path: /crates/web-sys/src/features/gen_XrFrame.rs #![allow(unused_imports)] #![allow(clippy::all)] use super::*; use wasm_bindgen::prelude::*; #[cfg(web_sys_unstable_apis)] #[wasm_bindgen] extern "C" { # [wasm_bindgen (extends = :: js_sys :: Object , js_name = XRFrame ,...
code_fim
hard
{ "lang": "rust", "repo": "rustwasm/wasm-bindgen", "path": "/crates/web-sys/src/features/gen_XrFrame.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>doc = "The `fillPoses()` method."] #[doc = ""] #[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/XRFrame/fillPoses)"] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `XrFrame`, `XrSpace`*"] #[doc = ""] #[doc = "*This...
code_fim
hard
{ "lang": "rust", "repo": "rustwasm/wasm-bindgen", "path": "/crates/web-sys/src/features/gen_XrFrame.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Chralt98/substrate-kitties path: /pallets/kitties/src/lib.rs #![cfg_attr(not(feature = "std"), no_std)] pub use pallet::*; #[frame_support::pallet] pub mod pallet { use frame_support::pallet_prelude::*; use frame_support::sp_runtime::traits::Hash; use frame_support::traits::Randomness; use ...
code_fim
hard
{ "lang": "rust", "repo": "Chralt98/substrate-kitties", "path": "/pallets/kitties/src/lib.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> Gender::Male } } //** These are all our **// //** helper functions. **// impl<T: Config> Kitty<T, T> { pub fn gender(dna: T::Hash) -> Gender { if dna.as_ref()[0] % 2 == 0 { Gender::Male } else { Gender::Female } } } #[pallet::call] impl<T: Config> Pallet<T> { } // EX...
code_fim
hard
{ "lang": "rust", "repo": "Chralt98/substrate-kitties", "path": "/pallets/kitties/src/lib.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll<Result<()>> { Poll::Ready(Ok(())) } } impl From<SyncRawPacketStream> for RawPacketStream { fn from(mut sync: SyncRawPacketStream) -> RawPacketStream { sync.set_non_blocking().expect("could not set non-block...
code_fim
hard
{ "lang": "rust", "repo": "nyantec/afpacket", "path": "/src/tokio.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nyantec/afpacket path: /src/tokio.rs use std::task::{Context, Poll}; use std::io::{Read, Write, Result}; use std::pin::Pin; use std::sync::Arc; use std::os::unix::prelude::{AsRawFd, FromRawFd, RawFd}; use super::sync::RawPacketStream as SyncRawPacketStream; pub use super::sync::{Filter, FilterPr...
code_fim
hard
{ "lang": "rust", "repo": "nyantec/afpacket", "path": "/src/tokio.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kevinkassimo/rusty_v8 path: /src/context.rs use crate::isolate::Isolate; use crate::isolate::LockedIsolate; use crate::support::Opaque; use crate::HandleScope; use crate::Local; use crate::Object; extern "C" { fn v8__Context__New(isolate: *mut Isolate) -> *mut Context; fn v8__Context__Enter...
code_fim
medium
{ "lang": "rust", "repo": "kevinkassimo/rusty_v8", "path": "/src/context.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn v8__Context__Exit(this: &mut Context); fn v8__Context__GetIsolate(this: &mut Context) -> *mut Isolate; fn v8__Context__Global(this: *mut Context) -> *mut Object; } #[repr(C)] pub struct Context(Opaque); impl Context { pub fn new<'sc>(scope: &mut HandleScope<'sc>) -> Local<'sc, Context> { ...
code_fim
medium
{ "lang": "rust", "repo": "kevinkassimo/rusty_v8", "path": "/src/context.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SkipHendriks/RustyInvaders path: /src/gpufrontend.rs use glium::{DisplayBuild, Surface, VertexBuffer, Program}; use glium::backend::glutin_backend::GlutinFacade; use glium::{glutin, index, uniforms}; extern crate glium; use game::{Vertex}; pub struct GpuFrontend { display: GlutinFacade, ...
code_fim
hard
{ "lang": "rust", "repo": "SkipHendriks/RustyInvaders", "path": "/src/gpufrontend.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn draw(&self, vertex_buffer: &glium::VertexBuffer<Vertex>, position: f32, rotation: f32, texture: &glium::Texture2d) { let mut target = self.display.draw(); target.clear_color(0.0, 0.0, 1.0, 1.0); let uniforms = uniform! { pos_matrix: [ [1.0, ...
code_fim
hard
{ "lang": "rust", "repo": "SkipHendriks/RustyInvaders", "path": "/src/gpufrontend.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: swlynch99/pelikan path: /src/proxy/momento/src/protocol/resp/hvals.rs // Copyright 2023 Pelikan Foundation LLC. // Licensed under the Apache License, Version 2.0 // http://www.apache.org/licenses/LICENSE-2.0 use crate::klog::*; use crate::{Error, *}; use ::net::*; use protocol_resp::*; pub asy...
code_fim
hard
{ "lang": "rust", "repo": "swlynch99/pelikan", "path": "/src/proxy/momento/src/protocol/resp/hvals.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for value in dictionary.values() { let value_header = format!("${}\r\n", value.len()); response_buf.extend_from_slice(value_header.as_bytes()); response_buf.extend_from_slice(value); ...
code_fim
hard
{ "lang": "rust", "repo": "swlynch99/pelikan", "path": "/src/proxy/momento/src/protocol/resp/hvals.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match action { ActionType::Entertainment => "entertainment", ActionType::Task(Priority::JustForFun) => "fun", ActionType::Task(Priority::NiceToHave) => "nice", ActionType::Task(Priority::Useful) => "useful", ActionType::Task(Priority::Important) => "important", ...
code_fim
hard
{ "lang": "rust", "repo": "gjersvik/ompa", "path": "/src/ole_martin/views.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gjersvik/ompa path: /src/ole_martin/views.rs use super::messages::{ActionType, InternalAction, Priority}; use lazy_static::lazy_static; use tera::{compile_templates, Context, Tera}; /// Load in templates from the project template folder. lazy_static! { static ref TERA: Tera = { let ...
code_fim
hard
{ "lang": "rust", "repo": "gjersvik/ompa", "path": "/src/ole_martin/views.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nelhage/ultimattt path: /src/lib/table.rs use parking_lot::Mutex; use serde::Serialize; use std::cell::UnsafeCell; use std::mem::MaybeUninit; use std::sync::atomic::{AtomicU32, AtomicUsize, Ordering}; use std::{fs, io, mem, ptr, slice}; mod entry_mutex; use entry_mutex::EntryMutex; #[derive(D...
code_fim
hard
{ "lang": "rust", "repo": "nelhage/ultimattt", "path": "/src/lib/table.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct ConcurrentTranspositionTable<E, const N: usize> where E: AtomicEntry + Default, { index: Box<[UnsafeCell<u8>]>, entries: Box<[UnsafeCell<E>]>, len: usize, handles: AtomicUsize, stats: Mutex<Stats>, } unsafe impl<E, const N: usize> Sync for ConcurrentTranspositionTable...
code_fim
hard
{ "lang": "rust", "repo": "nelhage/ultimattt", "path": "/src/lib/table.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> handles: AtomicUsize, stats: Mutex<Stats>, } unsafe impl<E, const N: usize> Sync for ConcurrentTranspositionTable<E, N> where E: AtomicEntry + Default { } unsafe impl<E, const N: usize> Send for ConcurrentTranspositionTable<E, N> where E: AtomicEntry + Default { } impl<E, const N: usize...
code_fim
hard
{ "lang": "rust", "repo": "nelhage/ultimattt", "path": "/src/lib/table.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Admiral-Frost/buttplug-rs-ffi path: /ffi/src/client.rs use super::{ FFICallback, device::ButtplugFFIDevice, flatbuffer_client_generated::buttplug_ffi::{ClientMessage, ClientMessageType, get_root_as_client_message, DeviceCommunicationManagerTypes}, flatbuffer_create_device_generated::butt...
code_fim
hard
{ "lang": "rust", "repo": "Admiral-Frost/buttplug-rs-ffi", "path": "/ffi/src/client.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let connect_websocket = client_msg.message_as_connect_websocket().unwrap(); let address = connect_websocket.address().unwrap().to_owned(); let bypass_cert_verify = connect_websocket.bypass_cert_verification(); let client_msg_id = client_msg.id(); let connector: ButtplugRemoteClientConn...
code_fim
hard
{ "lang": "rust", "repo": "Admiral-Frost/buttplug-rs-ffi", "path": "/ffi/src/client.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>// Precomputed values for Galois field multiplication pub const GF: [[u8; 256]; 7] = [ [ 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 195, 211, 227, 243, 131, 147, 163, 179, 67, 83, 99, 115, 3, 19, 35, 51, 69, 85, 101, 117, 5, 21, 37, 53, 197, 213, 22...
code_fim
hard
{ "lang": "rust", "repo": "Lawliet-Chan/phala-pruntime", "path": "/vendor/rustcrypto-block-ciphers/kuznyechik/src/consts.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Lawliet-Chan/phala-pruntime path: /vendor/rustcrypto-block-ciphers/kuznyechik/src/consts.rs /// Substitution table pub const P: [u8; 256] = [ 252, 238, 221, 17, 207, 110, 49, 22, 251, 196, 250, 218, 35, 197, 4, 77, 233, 119, 240, 219, 147, 46, 153, 186, 23, 54, 241, 187, 20, 205, 95, 193...
code_fim
hard
{ "lang": "rust", "repo": "Lawliet-Chan/phala-pruntime", "path": "/vendor/rustcrypto-block-ciphers/kuznyechik/src/consts.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> //unit tuple let empty_tuple = (); //used in match statements for doing nothing at the end of a branch //procedures are actually functions that return an empty tuple }<|fim_prefix|>// repo: thanathip-wisesight/rust-practice path: /practices/src/tuples.rs // Tuples group together values of...
code_fim
medium
{ "lang": "rust", "repo": "thanathip-wisesight/rust-practice", "path": "/practices/src/tuples.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thanathip-wisesight/rust-practice path: /practices/src/tuples.rs // Tuples group together values of different types // Max 12 elements #[allow(unused_variables)] pub fn run() { let person: (&str, &str, i8) = ("John", "Dave", 30); <|fim_suffix|> //unit tuple let empty_tuple = (); ...
code_fim
hard
{ "lang": "rust", "repo": "thanathip-wisesight/rust-practice", "path": "/practices/src/tuples.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (my_red, my_green, my_blue) = some_color; println!("r {} g {}, b {}", my_red, my_green, my_blue); //unit tuple let empty_tuple = (); //used in match statements for doing nothing at the end of a branch //procedures are actually functions that return an empty tuple }<|fim_prefix...
code_fim
medium
{ "lang": "rust", "repo": "thanathip-wisesight/rust-practice", "path": "/practices/src/tuples.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NajmusSaqib/rustgym path: /tfrs/src/creation/diag.rs use crate::core::*; impl TensorFlow { pub fn diag(&mut self, id: TensorId) -> TensorId { use TensorId::*; self.register(match id { F32(_) => diag(self.get(id).as_f32()), I32(_) => diag(self.get(id)....
code_fim
hard
{ "lang": "rust", "repo": "NajmusSaqib/rustgym", "path": "/tfrs/src/creation/diag.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let a_id = tf.tensor3d( vec![ 8.0, 5.0, 5.0, 7.0, 9.0, 10.0, 15.0, 1.0, 2.0, 14.0, 12.0, 3.0, ], vec![2, 2, 3], ); let b_id = tf.diag(a_id); let b = tf.get(b_id); let c = Tensor::new( vec![ 8.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ...
code_fim
hard
{ "lang": "rust", "repo": "NajmusSaqib/rustgym", "path": "/tfrs/src/creation/diag.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn gt(&self, other: Value) -> ValueResult { match self { Value::Function(_) => Err(RuntimeError::CannotCompare { typ: "function" }), Value::String(string) => Ok(Value::Bool(string.as_str() > other.to_str()?)), Value::Number(number) => Ok(Value::Bool(...
code_fim
hard
{ "lang": "rust", "repo": "jawadcode/stacc", "path": "/src/interpreter/value.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jawadcode/stacc path: /src/interpreter/value.rs use std::fmt; use crate::ast::Stmt; use super::{RuntimeError, ValueResult}; #[derive(Clone, Debug)] pub enum Value { Function(Function), String(String), Number(f64), Bool(bool), } #[derive(Clone, Debug)] pub struc...
code_fim
hard
{ "lang": "rust", "repo": "jawadcode/stacc", "path": "/src/interpreter/value.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn ne(&self, other: Value) -> ValueResult { match self { Value::Function(_) => Err(RuntimeError::CannotCompare { typ: "function" }), Value::String(string) => Ok(Value::Bool(string != other.to_str()?)), Value::Number(number) => Ok(Value::Bool(*number ...
code_fim
hard
{ "lang": "rust", "repo": "jawadcode/stacc", "path": "/src/interpreter/value.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mozilla/gecko-dev path: /third_party/rust/coremidi/src/ports.rs use core_foundation::base::OSStatus; use coremidi_sys::{MIDIPortConnectSource, MIDIPortDisconnectSource, MIDIPortDispose, MIDISend}; use std::ops::Deref; use std::ptr; use crate::callback::BoxedCallback; use crate::endpoints::des...
code_fim
hard
{ "lang": "rust", "repo": "mozilla/gecko-dev", "path": "/third_party/rust/coremidi/src/ports.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>impl InputPort { pub fn connect_source(&self, source: &Source) -> Result<(), OSStatus> { let status = unsafe { MIDIPortConnectSource(self.object.0, source.object.0, ptr::null_mut()) }; if status == 0 { Ok(()) } else { Err(status) } ...
code_fim
hard
{ "lang": "rust", "repo": "mozilla/gecko-dev", "path": "/third_party/rust/coremidi/src/ports.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> // Highest level has 1 block, next has 2, next 4 assert_eq!(tree.flat_blocks[0].order_free, 19); assert_eq!(tree.flat_blocks[1].order_free, 18); assert_eq!(tree.flat_blocks[2].order_free, 18); assert_eq!(tree.flat_blocks[3].order_free, 17); assert_eq!(tree...
code_fim
hard
{ "lang": "rust", "repo": "flower-os/flower", "path": "/kernel/src/memory/buddy_allocator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flower-os/flower path: /kernel/src/memory/buddy_allocator.rs /// A block in the bitmap #[derive(Copy, Clone)] pub struct Block { /// The order of the biggest block under this block - 1. 0 denotes used pub order_free: u8, } impl Block { pub fn new_free(order: u8) -> Self { Bl...
code_fim
hard
{ "lang": "rust", "repo": "flower-os/flower", "path": "/kernel/src/memory/buddy_allocator.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Iterate upwards and set parents accordingly for order in order + 1..=MAX_ORDER { node_index = flat_tree::parent(node_index); self.update_block(node_index, order); } } } } } #[cfg(test)] mod ...
code_fim
hard
{ "lang": "rust", "repo": "flower-os/flower", "path": "/kernel/src/memory/buddy_allocator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl <F: FnOnce() -> isize> FnBoxGeneric<isize> for F { fn call_box(self: Box<F>) -> Option<isize> { Some((*self)()) } } impl <F: FnOnce() -> u8> FnBoxGeneric<u8> for F { fn call_box(self: Box<F>) -> Option<u8> { Some((*self)()) } } impl <F: FnOnce() -> u16> FnBoxGeneri...
code_fim
hard
{ "lang": "rust", "repo": "asevans48/threadpools", "path": "/src/transport/thunk.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: asevans48/threadpools path: /src/transport/thunk.rs /// A thunk capable of sharing routines between threads /// @author aevans use std::any::Any; use serde::ser::{Serialize, Serializer, SerializeStruct}; pub trait FnBox { fn call_box(self: Box<Self>); } impl <F: FnOnce()> FnBox for F { ...
code_fim
hard
{ "lang": "rust", "repo": "asevans48/threadpools", "path": "/src/transport/thunk.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }