text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: moshg/rust-std-ja path: /src/librustc/infer/outlives/obligations.rs two //! kinds of constraints for the region inferencer: //! //! - Relationships between inference variables and other regions. //! For example, if we have `&'?0 u32: 'a`, then we would produce //! a constraint that `'a <= '...
code_fim
hard
{ "lang": "rust", "repo": "moshg/rust-std-ja", "path": "/src/librustc/infer/outlives/obligations.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut bounds = ty.walk_shallow().map(|subty| self.type_bound(subty)).collect::<Vec<_>>(); let mut regions = ty.regions(); regions.retain(|r| !r.is_late_bound()); // ignore late-bound regions bounds.push(VerifyBound::AllRegions(regions)); // remove bounds that mu...
code_fim
hard
{ "lang": "rust", "repo": "moshg/rust-std-ja", "path": "/src/librustc/infer/outlives/obligations.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> VerifyBound::AnyRegion(param_bounds) } fn projection_declared_bounds( &self, projection_ty: ty::ProjectionTy<'tcx>, ) -> Vec<ty::Region<'tcx>> { // First assemble bounds from where clauses and traits. let mut declared_bounds = self.declared...
code_fim
hard
{ "lang": "rust", "repo": "moshg/rust-std-ja", "path": "/src/librustc/infer/outlives/obligations.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: STRRL/dejavu path: /src/screenshot.rs use std::sync::{Arc, Mutex}; use anyhow::anyhow; use async_trait::async_trait; use image::DynamicImage; use screenshots::{Image, Screen}; #[async_trait] pub trait Capturer { /// Capture the contents of all the screens, returning a vector of images. ...
code_fim
hard
{ "lang": "rust", "repo": "STRRL/dejavu", "path": "/src/screenshot.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct Screenshot { pub image: DynamicImage, pub metadata: Metadata, } #[async_trait] impl Capturer for DefaultCapturer { async fn capture(&self) -> anyhow::Result<Vec<Screenshot>> { let now_epoch = chrono::Utc::now().timestamp() as u64; let screens = Scre...
code_fim
hard
{ "lang": "rust", "repo": "STRRL/dejavu", "path": "/src/screenshot.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[async_trait] impl Capturer for DefaultCapturer { async fn capture(&self) -> anyhow::Result<Vec<Screenshot>> { let now_epoch = chrono::Utc::now().timestamp() as u64; let screens = Screen::all()?; let result: Vec<Screenshot> = Vec::new(); let result_mutex = Arc::new(Mu...
code_fim
hard
{ "lang": "rust", "repo": "STRRL/dejavu", "path": "/src/screenshot.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hw0lff/tab-rs path: /tab-command/src/env.rs use crossterm::terminal; use tab_api::env::is_raw_mode; <|fim_suffix|>rr| err.into()) } else { Ok((80, 24)) } }<|fim_middle|> pub fn terminal_size() -> anyhow::Result<(u16, u16)> { if is_raw_mode() { terminal::size().map_err...
code_fim
medium
{ "lang": "rust", "repo": "hw0lff/tab-rs", "path": "/tab-command/src/env.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>rr| err.into()) } else { Ok((80, 24)) } }<|fim_prefix|>// repo: hw0lff/tab-rs path: /tab-command/src/env.rs use crossterm::terminal; use tab_api::env::is_raw_mode; pub fn terminal_size() -> anyhow::Result<(u16, u16)> { <|fim_middle|> if is_raw_mode() { terminal::size().map_err...
code_fim
easy
{ "lang": "rust", "repo": "hw0lff/tab-rs", "path": "/tab-command/src/env.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aohan237/http_router path: /src/baidu.rs extern crate hyper; extern crate hyper_tls; extern crate reqwest; extern crate serde; extern crate serde_json; use hyper::rt::{self, run, Future, Stream}; use hyper::Client; use hyper::{Body, Chunk, Error, Method, Request, Response, Server, StatusCode}; ...
code_fim
hard
{ "lang": "rust", "repo": "aohan237/http_router", "path": "/src/baidu.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn recog(&mut self, img_content: String, top_num: i32) -> ResponseFuture { let append_url = format!("?access_token={}&charset=UTF-8", self.get_token()); let url = String::from("https://aip.baidubce.com/rpc/2.0/ai_custom/v1/classification/recog") + &append_url; l...
code_fim
hard
{ "lang": "rust", "repo": "aohan237/http_router", "path": "/src/baidu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn say_foo() -> String { transitive_dep::say_something() }<|fim_prefix|>// repo: chromium/chromium path: /build/rust/tests/test_rust_metadata/foo_dependency.rs // Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE ...
code_fim
medium
{ "lang": "rust", "repo": "chromium/chromium", "path": "/build/rust/tests/test_rust_metadata/foo_dependency.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chromium/chromium path: /build/rust/tests/test_rust_metadata/foo_dependency.rs // Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. <|fim_suffix|>pub fn say_foo() -> String { transitive_dep::say_someth...
code_fim
medium
{ "lang": "rust", "repo": "chromium/chromium", "path": "/build/rust/tests/test_rust_metadata/foo_dependency.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Winseven4lyf/rust-debounced-pin path: /src/tests.rs use crate::prelude::*; use embedded_hal::digital::v2::InputPin; use failure::Fail; use mocks::*; /// Mock implementations. mod mocks { use super::*; #[derive(Debug, Fail)] #[fail(display = "An error occurred")] pub struct Mock...
code_fim
hard
{ "lang": "rust", "repo": "Winseven4lyf/rust-debounced-pin", "path": "/src/tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut pin = create_pin(); pin.debounce_state = DebounceState::Active; assert_eq!(pin.is_active(), true); pin.debounce_state = DebounceState::NotActive; assert_eq!(pin.is_active(), false); pin.debounce_state = DebounceState::Debounci...
code_fim
hard
{ "lang": "rust", "repo": "Winseven4lyf/rust-debounced-pin", "path": "/src/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn it_updates_the_counter() -> Result<(), MockInputPinError> { let mut pin = create_pin(); pin.pin.state = false; assert_eq!(pin.counter, 0); pin.update()?; assert_eq!(pin.counter, 1); Ok(()) } ...
code_fim
hard
{ "lang": "rust", "repo": "Winseven4lyf/rust-debounced-pin", "path": "/src/tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HoOngEe/codechain-dashboard path: /server/src/agent/handler.rs use ws; use ws::{CloseCode, Error as WSError, Handler, Handshake, Result, Sender as WSSender}; use super::super::agent; use super::super::jsonrpc; pub struct WebSocketHandler { pub out: WSSender, pub count: usize, pub a...
code_fim
hard
{ "lang": "rust", "repo": "HoOngEe/codechain-dashboard", "path": "/server/src/agent/handler.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // The connection is going down, so we need to decrement the count self.count -= 1; } fn on_error(&mut self, err: WSError) { cerror!("The server encountered an error: {:?}", err); } }<|fim_prefix|>// repo: HoOngEe/codechain-dashboard path: /server/src/agent/handler.rs...
code_fim
hard
{ "lang": "rust", "repo": "HoOngEe/codechain-dashboard", "path": "/server/src/agent/handler.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ryanmtate/fluvio path: /src/cli/src/topic/create.rs //! //! # Create Topics //! //! CLI tree to generate Create Topics //! use std::io::Error as IoError; use std::io::ErrorKind; use std::path::PathBuf; use structopt::StructOpt; use flv_client::SpuController; use flv_client::query_params::Repl...
code_fim
hard
{ "lang": "rust", "repo": "Ryanmtate/fluvio", "path": "/src/cli/src/topic/create.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ReplicaConfig::Computed( self.partitions, self.replication, self.ignore_rack_assigment, ) } /// Ensure all parameters are valid for computed replication fn parse_assigned_replica(&self) -> Result<ReplicaConfig, CliError> { if let Som...
code_fim
hard
{ "lang": "rust", "repo": "Ryanmtate/fluvio", "path": "/src/cli/src/topic/create.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl CreateTopicOpt { /// Ensure all parameters are valid for computed replication fn parse_computed_replica(&self) -> ReplicaConfig { ReplicaConfig::Computed( self.partitions, self.replication, self.ignore_rack_assigment, ) } /// Ensure...
code_fim
hard
{ "lang": "rust", "repo": "Ryanmtate/fluvio", "path": "/src/cli/src/topic/create.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut allocator = DeviceAllocator::new(); let d = create_cdc_device(&mut allocator); let config = d.build(); let device_config = allocator.into(); generate_file(out_dir.join("generated.rs"), config, device_config).unwrap(); } fn main() { // Put the linker script somewhere the li...
code_fim
hard
{ "lang": "rust", "repo": "Disasm/usb-test", "path": "/build.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Disasm/usb-test path: /build.rs use std::env; use std::fs::File; use std::io::Write; use std::path::PathBuf; use usb_device_generator::{UsbDirection, EndpointType}; use usb_device_generator::builder::{EndpointBuilder, DeviceBuilder, UsbVidPid}; use usb_device_generator::generator::generate_file;...
code_fim
hard
{ "lang": "rust", "repo": "Disasm/usb-test", "path": "/build.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: input-output-hk/chain-libs path: /chain-impl-mockchain/src/accounting/account/account_state.rs type Item = (&'a ID, &'a AccountState<Extra>); fn next(&mut self) -> Option<Self::Item> { self.0.next() } } #[cfg(test)] mod tests { use super::{ AccountState, Delegation...
code_fim
hard
{ "lang": "rust", "repo": "input-output-hk/chain-libs", "path": "/chain-impl-mockchain/src/accounting/account/account_state.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] pub fn delegation_ratio_zero_pool_parts() { let fake_pool_id = StakePoolBuilder::new().build().id(); let parts = 8u8; let pools: Vec<(PoolId, u8)> = vec![ (fake_pool_id.clone(), 0u8), (fake_pool_id.clone(), 3u8), (fake_pool_id, 3u...
code_fim
hard
{ "lang": "rust", "repo": "input-output-hk/chain-libs", "path": "/chain-impl-mockchain/src/accounting/account/account_state.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: input-output-hk/chain-libs path: /chain-impl-mockchain/src/accounting/account/account_state.rs (init_value, ()); let counter = SpendingCounter::from(counter); account_state.spending = SpendingCounterIncreasing::new_from_counter(counter); assert_eq!( should_sub...
code_fim
hard
{ "lang": "rust", "repo": "input-output-hk/chain-libs", "path": "/chain-impl-mockchain/src/accounting/account/account_state.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nbaksalyar/yewprint path: /yewprint/src/text.rs use crate::ConditionalClass; use yew::prelude::*; pub struct Text { props: Props, } #[derive(Clone, PartialEq, Properties)] pub struct Props { #[prop_or_default] pub ellipsize: ConditionalClass, #[prop_or_default] pub text: St...
code_fim
medium
{ "lang": "rust", "repo": "nbaksalyar/yewprint", "path": "/yewprint/src/text.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> html! { <p class=( "bp3-text", self.props.ellipsize.map_some("bp3-text-overflow-ellipsis"), ) > {self.props.text.clone()} </p> } } }<|fim_prefix|>// repo: nbaksal...
code_fim
medium
{ "lang": "rust", "repo": "nbaksalyar/yewprint", "path": "/yewprint/src/text.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bmacnaughton/napi-rs path: /examples/napi-compat-mode/src/napi4/tsfn_dua_instance.rs use napi::{ threadsafe_function::{ThreadSafeCallContext, ThreadsafeFunction}, CallContext, JsFunction, JsObject, JsUndefined, }; use napi_derive::js_function; #[derive(Clone)] struct A { cb: ThreadsafeFun...
code_fim
hard
{ "lang": "rust", "repo": "bmacnaughton/napi-rs", "path": "/examples/napi-compat-mode/src/napi4/tsfn_dua_instance.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[js_function(1)] pub fn constructor(ctx: CallContext) -> napi::Result<JsUndefined> { let callback = ctx.get::<JsFunction>(0)?; let mut cb = ctx .env .create_threadsafe_function(&callback, 0, |ctx: ThreadSafeCallContext<String>| { ctx .env .create_string_fr...
code_fim
medium
{ "lang": "rust", "repo": "bmacnaughton/napi-rs", "path": "/examples/napi-compat-mode/src/napi4/tsfn_dua_instance.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PedroDiogo/AdventOfCode2020 path: /benches/benchmarks.rs extern crate advent_of_code_2020; extern crate criterion; use advent_of_code_2020::days::*; use criterion::*; <|fim_suffix|>benchmark!(day1, day1::run); benchmark!(day2, day2::run); benchmark!(day3, day3::run); benchmark!(day4, day4::run...
code_fim
medium
{ "lang": "rust", "repo": "PedroDiogo/AdventOfCode2020", "path": "/benches/benchmarks.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>criterion_group!( benches, day1, day2, day3, day4, day5, day6, day7, day8, day9, day10, day11, day12, day13, day14, day15, day16, day17, day18, day19 ); criterion_main!(benches);<|fim_prefix|>// repo: PedroDiogo/AdventOfCode2020 path: /benches/benchmarks.rs extern crate advent_of_code_2020; exter...
code_fim
hard
{ "lang": "rust", "repo": "PedroDiogo/AdventOfCode2020", "path": "/benches/benchmarks.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut word = String::from(""); if direct == "W" { for k in j..cmp::min(SEARCH_X-1, j+max_word_len) { word.push(search[i][k]); } } if direct == "E" { let mut adj_j: usize = 0; let mut k: usize = j; if max_word_len < j {adj_j = j-max_word...
code_fim
hard
{ "lang": "rust", "repo": "Gorf963/WordFind", "path": "/src/process.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Gorf963/WordFind path: /src/process.rs use crate::{SEARCH_X, SEARCH_Y}; use std::cmp; pub fn brute(max_word_len: usize, word_list: &Vec<String>, search: [[char;SEARCH_X];SEARCH_Y]) -> Vec<String> { let mut temp_results: Vec<String> = Vec::new(); for i in 0..SEARCH_X-1 { for j...
code_fim
hard
{ "lang": "rust", "repo": "Gorf963/WordFind", "path": "/src/process.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Deserialize)] #[serde(rename_all = "lowercase")] pub enum ConversationSourceType { Email, Web, Notification, #[serde(rename = "emailfwd")] EmailForward, Api, Chat, } #[derive(Debug, Deserialize)] #[serde(rename_all = "lowercase")] pub enum ConversationSourceVia...
code_fim
hard
{ "lang": "rust", "repo": "Qwuke/helpscout-rs", "path": "/src/api/conversations.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Qwuke/helpscout-rs path: /src/api/conversations.rs use serde_json; use chrono::{DateTime, Utc}; use error::HelpScoutError; use client::Client; use envelope::Collection; use api::person::Person; use api::mailboxes::MailboxRef; #[derive(Debug, Deserialize)] #[serde(rename_all = "lowercase")] pub...
code_fim
hard
{ "lang": "rust", "repo": "Qwuke/helpscout-rs", "path": "/src/api/conversations.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: panicfrog/courier_server path: /src/router.rs use rocket::tokio::time::{sleep, Duration}; use rocket::serde::{ Deserialize, Serialize, json::Json }; use rocket::State; use rocket::response::status::Created; use rocket::request::Request; use super::db::{ Db, KV, query_latest_kv, insert_kv }; <...
code_fim
hard
{ "lang": "rust", "repo": "panicfrog/courier_server", "path": "/src/router.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[catch(500)] pub fn internal_error() -> &'static str { "Whoops! Looks like we messed up." } #[catch(400)] pub fn not_found(req: &Request) -> String { format!("I couldn't find '{}'. Try something else?", req.uri()) }<|fim_prefix|>// repo: panicfrog/courier_server path: /src/router.rs use rocket:...
code_fim
hard
{ "lang": "rust", "repo": "panicfrog/courier_server", "path": "/src/router.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[post("/setValue", format = "json", data = "<data>")] pub async fn set_value(db: &State<Db>, data: Json<KV>) -> Result<Created<Json<KV>>> { let (key, value) = (data.key.as_str(), data.value.as_str()); let _ = insert_kv(&**db, key, value).await?; Ok(Created::new("/").body(data)) } #[catch(500...
code_fim
hard
{ "lang": "rust", "repo": "panicfrog/courier_server", "path": "/src/router.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ArcWake for Waker { fn wake_by_ref(me: &Arc<Self>) { Task::schedule(&me.task, &me.pool); } }<|fim_prefix|>// repo: discord/tokio path: /tokio-threadpool/src/waker.rs use crate::pool::Pool; use crate::task::Task; use futures_util::task::ArcWake; use std::sync::Arc; <|fim_middle|>///...
code_fim
hard
{ "lang": "rust", "repo": "discord/tokio", "path": "/tokio-threadpool/src/waker.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: discord/tokio path: /tokio-threadpool/src/waker.rs use crate::pool::Pool; use crate::task::Task; use futures_util::task::ArcWake; use std::sync::Arc; /// Implements the future `Waker` API. /// /// This is how external events are able to signal the task, informing it to try /// to poll the futu...
code_fim
medium
{ "lang": "rust", "repo": "discord/tokio", "path": "/tokio-threadpool/src/waker.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ivan-jukic/connect4-rust-wasm path: /src/rust/enums/player.rs /// Player enum #[derive(Debug, Clone, PartialEq)] pub enum Player { On<|fim_suffix|> match player { Player::One => String::from("one"), Player::Two => String::from("two"), Player::AI => String::f...
code_fim
medium
{ "lang": "rust", "repo": "ivan-jukic/connect4-rust-wasm", "path": "/src/rust/enums/player.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>Two => String::from("two"), Player::AI => String::from("AI"), } }<|fim_prefix|>// repo: ivan-jukic/connect4-rust-wasm path: /src/rust/enums/player.rs /// Player enum #[derive(Debug, Clone, PartialEq)] pub enum Player { On<|fim_middle|>e, Two, AI, } pub fn player_to_s...
code_fim
medium
{ "lang": "rust", "repo": "ivan-jukic/connect4-rust-wasm", "path": "/src/rust/enums/player.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let svdpath = yaml_dir.join(&yaml.svd); let svd = svd_reader::device(&svdpath)?; let yaml_dir = yaml_file.parent().unwrap(); include::yaml_includes(&mut yaml.body, yaml_dir); let mut patcher = Patcher { svd, yaml: yaml.body, }; patcher.process_device()?; ...
code_fim
medium
{ "lang": "rust", "repo": "MarcoIeni/svdtools", "path": "/src/patch/patch_cli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let svdpath_out = svdpath.with_extension("svd.patched"); let mut out_file = File::create(svdpath_out).unwrap(); out_file.write_all(xml_out.as_bytes()).unwrap(); Ok(()) }<|fim_prefix|>// repo: MarcoIeni/svdtools path: /src/patch/patch_cli.rs use crate::common::svd_reader; use crate::patch:...
code_fim
hard
{ "lang": "rust", "repo": "MarcoIeni/svdtools", "path": "/src/patch/patch_cli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MarcoIeni/svdtools path: /src/patch/patch_cli.rs use crate::common::svd_reader; use crate::patch::include; use crate::patch::patcher::Patcher; use crate::patch::yaml::yaml_parser; use anyhow::Result; use std::io::Write; use std::{fs::File, path::Path}; use svd_parser; use yaml_parser::YamlRoot; ...
code_fim
hard
{ "lang": "rust", "repo": "MarcoIeni/svdtools", "path": "/src/patch/patch_cli.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhao1jin4/vscode_rust_workspace path: /cargo_projects/mytest/tests/common.rs pub fn setup() { // 编写特定库测试所需的代码 println!("perpare test ----"); } //文件名不叫lib.rs,单元测试不能跑?? //编译提示 either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present fn main(){ println!(...
code_fim
hard
{ "lang": "rust", "repo": "zhao1jin4/vscode_rust_workspace", "path": "/cargo_projects/mytest/tests/common.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Guess::new(200); } #[test] fn internal() { assert_eq!(4, internal_adder(2, 2));//可以测试私有函数,因已经 use } } #[derive(Debug)] struct Rectangle { width: u32, height: u32, } impl Rectangle { fn can_hold(&self, other: &Rectangle) -> bool { self.width > oth...
code_fim
hard
{ "lang": "rust", "repo": "zhao1jin4/vscode_rust_workspace", "path": "/cargo_projects/mytest/tests/common.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bruceherve/graph-node path: /datasource/ethereum/src/ethereum_adapter.rs t + 100_000 - 1) .min(to) .min(*LOG_STREAM_FAST_SCAN_END); debug!( logger, "Starting request for logs in b...
code_fim
hard
{ "lang": "rust", "repo": "bruceherve/graph-node", "path": "/datasource/ethereum/src/ethereum_adapter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bruceherve/graph-node path: /datasource/ethereum/src/ethereum_adapter.rs .map(move |logs| { logs.into_iter() // Filter out false positives .filter(move |log| log_filter....
code_fim
hard
{ "lang": "rust", "repo": "bruceherve/graph-node", "path": "/datasource/ethereum/src/ethereum_adapter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self, logger: &Logger, block_hash: H256, ) -> Box<Future<Item = Option<Block<Transaction>>, Error = Error> + Send> { let web3 = self.web3.clone(); let logger = logger.clone(); Box::new( retry("eth_getBlockByHash RPC call", &logger) ...
code_fim
hard
{ "lang": "rust", "repo": "bruceherve/graph-node", "path": "/datasource/ethereum/src/ethereum_adapter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut img: RgbImage = ImageBuffer::new(canvas.width() as u32, canvas.height() as u32); for y in 0..canvas.height() { for x in 0..canvas.width() { let color = canvas.get_pixel(x, y); let r = scale_color_component(color.red); let ...
code_fim
medium
{ "lang": "rust", "repo": "tlinford/raytracer-challenge-rs", "path": "/raytracer/src/image/png.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tlinford/raytracer-challenge-rs path: /raytracer/src/image/png.rs use std::path::Path; use anyhow::Result; use image::{ImageBuffer, RgbImage}; use super::ExportCanvas; use crate::canvas::Canvas; <|fim_suffix|> let mut img: RgbImage = ImageBuffer::new(canvas.width() as u32, canvas.heigh...
code_fim
medium
{ "lang": "rust", "repo": "tlinford/raytracer-challenge-rs", "path": "/raytracer/src/image/png.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chmod222/AdventOfCode-2018 path: /Rust/day4/src/main.rs use chrono::{DateTime, TimeZone, Utc, Timelike}; type GuardId = u16; #[derive(Debug)] enum GuardEventType { ShiftBegin(GuardId), FallsAsleep, WakesUp } type TimeStamp = DateTime<Utc>; #[derive(Debug)] struct GuardEvent(TimeS...
code_fim
hard
{ "lang": "rust", "repo": "chmod222/AdventOfCode-2018", "path": "/Rust/day4/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let most_frequent = sleepy_guards .iter() .filter_map(|guard| { // Turn id:guard into (id, minute, count_asleep) let most = guard.1.sleep_times .iter() .max_by(|a, b| a.1.cmp(b.1))?; // Find most often asleep minute S...
code_fim
hard
{ "lang": "rust", "repo": "chmod222/AdventOfCode-2018", "path": "/Rust/day4/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> msg_send![slider, setTarget:responder]; msg_send![slider, setAction:sel!(onMouseMove:)]; Slider { id: slider } }; slider } pub fn set_slider_type(&mut self, value: SliderStyle) { unsafe { msg_send![self.id, setSliderType:value as u32] ...
code_fim
hard
{ "lang": "rust", "repo": "monomadic/tinyui-rs", "path": "/src/platform/cocoa/slider.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: monomadic/tinyui-rs path: /src/platform/cocoa/slider.rs #![allow(non_snake_case)] #![allow(unused_variables)] #![allow(unused_imports)] use cocoa::base::{ id, nil, NO, class }; use cocoa::foundation::{ NSString, NSAutoreleasePool }; use objc::runtime::{ Class, Object, Sel }; use objc::declare::...
code_fim
hard
{ "lang": "rust", "repo": "monomadic/tinyui-rs", "path": "/src/platform/cocoa/slider.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ousttrue/frame_factory path: /gen/src/imgui/imgui.rs ] #[derive(Clone, Copy, Default)] pub struct ImFontGlyph { pub Colored: u32, pub Visible: u32, pub Codepoint: u32, pub AdvanceX: f32, pub X0: f32, pub Y0: f32, pub X1: f32, pub Y1: f32, pub U0: f32, pub ...
code_fim
hard
{ "lang": "rust", "repo": "ousttrue/frame_factory", "path": "/gen/src/imgui/imgui.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[repr(C)] #[derive(Clone, Copy)] pub struct ImGuiTextBuffer { pub Buf: *mut c_void, } #[repr(C)] #[derive(Clone, Copy)] pub struct ImGuiStorage { pub Data: *mut c_void, } #[repr(C)] #[derive(Clone, Copy, Default)] pub struct ImGuiListClipper { pub DisplayStart: i32, pub DisplayEnd: i32,...
code_fim
hard
{ "lang": "rust", "repo": "ousttrue/frame_factory", "path": "/gen/src/imgui/imgui.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ousttrue/frame_factory path: /gen/src/imgui/imgui.rs , } #[repr(C)] #[derive(Clone, Copy)] pub struct ImDrawVert { pub pos: ImVec2, pub uv: ImVec2, pub col: u32, } #[repr(C)] #[derive(Clone, Copy)] pub struct ImDrawCmdHeader { pub ClipRect: ImVec4, pub TextureId: *mut c_voi...
code_fim
hard
{ "lang": "rust", "repo": "ousttrue/frame_factory", "path": "/gen/src/imgui/imgui.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the data field for the transaction. pub fn data(&self) -> Vec<u8> { match self { Sender::Basic { .. } | Sender::Htlc { .. } | Sender::Vesting { .. } => { vec![] } Sender::Staking { data } => data.serialize_to_vec(), } ...
code_fim
hard
{ "lang": "rust", "repo": "nimiq/core-rs-albatross", "path": "/transaction-builder/src/sender.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nimiq/core-rs-albatross path: /transaction-builder/src/sender.rs use nimiq_keys::Address; use nimiq_primitives::{account::AccountType, policy::Policy}; use nimiq_serde::Serialize; use nimiq_transaction::account::staking_contract::OutgoingStakingTransactionData; #[derive(Clone, Debug)] #[cfg_att...
code_fim
hard
{ "lang": "rust", "repo": "nimiq/core-rs-albatross", "path": "/transaction-builder/src/sender.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: basiliqio/ciboulette2pg path: /src/builder/extracting_data/main.rs use super::*; /// Extract attributes from the request and push them to an arguments vector /// compatible with SQLx for later execution pub fn attributes_to_sql_params<'store, 'request>( args: &m<|fim_suffix|>ches!(v, MessyJ...
code_fim
hard
{ "lang": "rust", "repo": "basiliqio/ciboulette2pg", "path": "/src/builder/extracting_data/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ches!(v, MessyJsonValue::Null(MessyJsonNullType::Absent, _)) { continue; } args.push((k.clone(), Ciboulette2PgValue::try_from(v)?)); } } Ok(()) }<|fim_prefix|>// repo: basiliqio/ciboulette2pg path: /src/builder/extracting_data/main.rs use super::*; ...
code_fim
hard
{ "lang": "rust", "repo": "basiliqio/ciboulette2pg", "path": "/src/builder/extracting_data/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zwhitchcox/leetcode_rs path: /src/_0242_valid_anagram.rs struct Solution; impl Solution { fn is_anagram(s: String, t: String) -> bool { <|fim_suffix|> assert_eq!( Solution::is_anagram("anagram".to_string(), "nagaram".to_string()), true ); assert_eq!( Solut...
code_fim
hard
{ "lang": "rust", "repo": "zwhitchcox/leetcode_rs", "path": "/src/_0242_valid_anagram.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jveiga/rtmp-switcher path: /src/input.rs extern crate gstreamer as gst; use gst::prelude::*; type Error = Box<dyn std::error::Error>; pub enum Input { URI(URI), } impl Input { pub fn from_uri(name: &str, uri: &str) -> Input { URI::new(name, uri).unwrap() } pub fn name...
code_fim
hard
{ "lang": "rust", "repo": "jveiga/rtmp-switcher", "path": "/src/input.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if new_pad_type.starts_with("audio/x-raw") { let sink_pad = audio .get_static_pad("sink") .expect("Failed to get sink pad from audio mixer"); if sink_pad.is_linked() { println!("We are already linked. I...
code_fim
hard
{ "lang": "rust", "repo": "jveiga/rtmp-switcher", "path": "/src/input.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> glfw::get_monitors().map(|monitor| { io::println(fmt!("%s:", monitor.get_name())); do monitor.get_video_modes().map |mode| { io::println(fmt!(" %s", mode.to_str())); } }); } }<|fim_prefix|>// repo: zofrex/glfw-rs path: ...
code_fim
hard
{ "lang": "rust", "repo": "zofrex/glfw-rs", "path": "/examples/modes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zofrex/glfw-rs path: /examples/modes.rs extern mod glfw; fn main() { do glfw::spawn { io::println(fmt!("Primary monitor: %s\n", glfw::get_primary_monitor().get_name())); <|fim_suffix|> glfw::get_monitors().map(|monitor| { io::println(fmt!("%s:", monitor.g...
code_fim
hard
{ "lang": "rust", "repo": "zofrex/glfw-rs", "path": "/examples/modes.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn manhattan_distance(v1: &Vector, v2: &Vector) -> i32 { let dx = (v1.get_x() - v2.get_x()).abs(); let dy = (v1.get_y() - v2.get_y()).abs(); return dx + dy; } pub fn get_x(&self) -> i32 { return self.x; } pub fn get_y(&self) -> i32 { retur...
code_fim
medium
{ "lang": "rust", "repo": "stbowers/Advent-of-Code-2018", "path": "/day6/src/vector.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_y(&self) -> i32 { return self.y; } }<|fim_prefix|>// repo: stbowers/Advent-of-Code-2018 path: /day6/src/vector.rs use std::ops::{Add, Sub}; pub struct Vector { x: i32, y: i32, } impl Vector { pub fn new(x: i32, y: i32) -> Vector { return Vector { x: x, y: ...
code_fim
hard
{ "lang": "rust", "repo": "stbowers/Advent-of-Code-2018", "path": "/day6/src/vector.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stbowers/Advent-of-Code-2018 path: /day6/src/vector.rs use std::ops::{Add, Sub}; pub struct Vector { x: i32, y: i32, } <|fim_suffix|> pub fn manhattan_distance(v1: &Vector, v2: &Vector) -> i32 { let dx = (v1.get_x() - v2.get_x()).abs(); let dy = (v1.get_y() - v2.get_...
code_fim
medium
{ "lang": "rust", "repo": "stbowers/Advent-of-Code-2018", "path": "/day6/src/vector.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> write!( f, "service request error code: {}, status: {}", self.0, self.1 ) } } impl std::error::Error for Error {}<|fim_prefix|>// repo: xoac/nats.rs path: /async-nats/src/service/error.rs // Copyright 2020-2022 The NATS Authors // Licensed under the...
code_fim
hard
{ "lang": "rust", "repo": "xoac/nats.rs", "path": "/async-nats/src/service/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xoac/nats.rs path: /async-nats/src/service/error.rs // Copyright 2020-2022 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.or...
code_fim
medium
{ "lang": "rust", "repo": "xoac/nats.rs", "path": "/async-nats/src/service/error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>mat().fmt(f), AnyJsClassMember::TsGetterSignatureClassMember(node) => node.format().fmt(f), AnyJsClassMember::TsSetterSignatureClassMember(node) => node.format().fmt(f), AnyJsClassMember::TsIndexSignatureClassMember(node) => node.format().fmt(f), AnyJsClassM...
code_fim
hard
{ "lang": "rust", "repo": "rome/tools", "path": "/crates/rome_js_formatter/src/js/any/class_member.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rome/tools path: /crates/rome_js_formatter/src/js/any/class_member.rs //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file. use crate::prelude::*; use rome_js_syntax::AnyJsClassMember; #[derive(Debug, Clone, Default)] pub(crate) struct For...
code_fim
hard
{ "lang": "rust", "repo": "rome/tools", "path": "/crates/rome_js_formatter/src/js/any/class_member.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fredyw/leetcode path: /src/main/rust/src/bin/problem2745.rs // https://leetcode.com/problems/construct-the-longest-new-string/ pub fn longest_string(x: i32, y: i32, z: i32) -> i32 { if x == y { (x * 2) + (y * 2) + (z * 2) } else { let min = x.min(y); (min * 2) + (...
code_fim
easy
{ "lang": "rust", "repo": "fredyw/leetcode", "path": "/src/main/rust/src/bin/problem2745.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", longest_string(2, 5, 1)); // 12 println!("{}", longest_string(3, 2, 2)); // 14 println!("{}", longest_string(40, 50, 24)); // 210 }<|fim_prefix|>// repo: fredyw/leetcode path: /src/main/rust/src/bin/problem2745.rs // https://leetcode.com/problems/construct-the-longest-new-strin...
code_fim
easy
{ "lang": "rust", "repo": "fredyw/leetcode", "path": "/src/main/rust/src/bin/problem2745.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut input = Box::into_raw(Box::new([2.0, 2.0, 1.0])) as *mut c_void; assert_eq!(linear_classify_input(modele, input, 2), 1.); input = Box::into_raw(Box::new([-5.0, -5.0, -2.0])) as *mut c_void; assert_eq!(linear_classify_input(modele, input, 2), -1.); input = ...
code_fim
hard
{ "lang": "rust", "repo": "Heinmci/MachineLearning", "path": "/src/public/linear/classification.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> input = Box::into_raw(Box::new([6.0, 5.0])) as *mut c_void; assert_eq!(linear_classify_input(modele, input, 2), -1.); input = Box::into_raw(Box::new([5.0, 3.0])) as *mut c_void; assert_eq!(linear_classify_input(modele, input, 2), -1.); input = Box::into_raw(Box::...
code_fim
hard
{ "lang": "rust", "repo": "Heinmci/MachineLearning", "path": "/src/public/linear/classification.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Heinmci/MachineLearning path: /src/public/linear/classification.rs use core::linear; use std::os::raw::c_void; // Return the value (-1 or 1) for given input parameters #[no_mangle] pub extern fn linear_classify_input(coefficients: *mut Vec<f64>, input: *mut c_void, array_length: i32) -> f64 { ...
code_fim
hard
{ "lang": "rust", "repo": "Heinmci/MachineLearning", "path": "/src/public/linear/classification.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PaulL48/comp442-compiler path: /ast/src/lib.rs // So as the semantic stack is built, // a<|fim_suffix|>t becomes a child in the ast being built. mod ast; pub use crate::ast::{Data, Node};<|fim_middle|>nytime an element is popped off the stack i
code_fim
easy
{ "lang": "rust", "repo": "PaulL48/comp442-compiler", "path": "/ast/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>t becomes a child in the ast being built. mod ast; pub use crate::ast::{Data, Node};<|fim_prefix|>// repo: PaulL48/comp442-compiler path: /ast/src/lib.rs // So as the semantic stack is built, // a<|fim_middle|>nytime an element is popped off the stack i
code_fim
easy
{ "lang": "rust", "repo": "PaulL48/comp442-compiler", "path": "/ast/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PaulL48/comp442-compiler path: /ast/src/lib.rs // So as the semantic stack is built, // anytime an element is popped off the stack i<|fim_suffix|>mod ast; pub use crate::ast::{Data, Node};<|fim_middle|>t becomes a child in the ast being built.
code_fim
easy
{ "lang": "rust", "repo": "PaulL48/comp442-compiler", "path": "/ast/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> [server] ip = "127.0.0.1" port = 80 [[peers]] ip = "127.0.0.1" port = 8080 [[peers]] ip = "127.0.0.1" "#; // Use the `decode_str` convenience here to decode a TOML string directly // into the `Config` struct. // // Note...
code_fim
medium
{ "lang": "rust", "repo": "vitiral/toml-rs", "path": "/examples/decode.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Use the `decode_str` convenience here to decode a TOML string directly // into the `Config` struct. // // Note that the errors reported here won't necessarily be the best, but you // can get higher fidelity errors working with `toml::Parser` directly. let decoded: Config = toml:...
code_fim
hard
{ "lang": "rust", "repo": "vitiral/toml-rs", "path": "/examples/decode.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vitiral/toml-rs path: /examples/decode.rs //! An example showing off the usage of `RustcDecodable` to automatically decode //! TOML into a Rust `struct` //! //! Note that this works similarly with `serde` as well. #![deny(warnings)] extern crate toml; extern crate rustc_serialize; /// This is...
code_fim
medium
{ "lang": "rust", "repo": "vitiral/toml-rs", "path": "/examples/decode.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sdroege/gst-plugin-rs path: /net/onvif/src/onvifmetadataoverlay/mod.rs use gst::glib; use gst::prelude::*; mod imp; <|fim_suffix|>pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> { gst::Element::register( Some(plugin), "onvifmetadataoverlay", gst...
code_fim
medium
{ "lang": "rust", "repo": "sdroege/gst-plugin-rs", "path": "/net/onvif/src/onvifmetadataoverlay/mod.rs", "mode": "psm", "license": "MPL-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spectrum-lumiere/contracts path: /contracts/spectrum_mirror_farm/src/bond.rs torage).save(&state)?; Ok(()) } pub fn deposit_spec_reward<S: Storage, A: Api, Q: Querier>( deps: &Extern<S, A, Q>, state: &mut State, config: &Config, height: u64, query: bool, ) -> StdResult<...
code_fim
hard
{ "lang": "rust", "repo": "spectrum-lumiere/contracts", "path": "/contracts/spectrum_mirror_farm/src/bond.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let locked_share = config.calc_locked_reward(reward_info.accum_spec_share, height); let withdraw_share = if locked_share >= reward_info.spec_share { Uint128::zero() } else { (reward_info.spec_share - locked_share)? }; spec_share += withdraw_s...
code_fim
hard
{ "lang": "rust", "repo": "spectrum-lumiere/contracts", "path": "/contracts/spectrum_mirror_farm/src/bond.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spectrum-lumiere/contracts path: /contracts/spectrum_mirror_farm/src/bond.rs _info_store(&mut deps.storage).save(asset_token_raw.as_slice(), &pool_info)?; state_store(&mut deps.storage).save(&state)?; stake_token( &deps.api, &config.mirror_staking, &pool_info.sta...
code_fim
hard
{ "lang": "rust", "repo": "spectrum-lumiere/contracts", "path": "/contracts/spectrum_mirror_farm/src/bond.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn locking(&self) -> Duration { self.locking } pub fn touching_floor(&mut self, stack: &Stack) -> bool { self.collision(0, 1, stack) } pub fn grid(&self) -> &ShapeGrid { &self.shape.grids[self.rotation] } pub fn shape(&self) -> ShapeType { ...
code_fim
hard
{ "lang": "rust", "repo": "piotrek-szczygiel/klocki", "path": "/src/piece.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if x == last_horizontal || y == last_vertical || stack[y + 1][x + 1] != 0 { occupied += 1; } occupied >= 3 } pub fn reset(&mut self, stack: &Stack) { self.x = (stack.width as f32 / 2.0 - self.shape.grids[0].width as f32 / 2.0) as i32; self.y = ...
code_fim
hard
{ "lang": "rust", "repo": "piotrek-szczygiel/klocki", "path": "/src/piece.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: piotrek-szczygiel/klocki path: /src/piece.rs use std::time::Duration; use ggez::{self, nalgebra::Point2, timer, Context, GameResult}; use crate::{ blocks::Blocks, shape::{Shape, ShapeGrid, ShapeType}, stack::Stack, }; #[derive(Clone, PartialEq)] pub enum Movement { None, S...
code_fim
hard
{ "lang": "rust", "repo": "piotrek-szczygiel/klocki", "path": "/src/piece.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thomcc/ulock-sys path: /src/lib.rs //! Bindings for macOS's not-entirely-public ulock API, which provides //! futex-like functionality. //! //! In general, caveat emptor. It's recommended that you read both the //! [source][sys_ulock_c] and the [header][ulock_h]. In particular, I've not //! docu...
code_fim
hard
{ "lang": "rust", "repo": "thomcc/ulock-sys", "path": "/src/lib.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(all(feature = "experimental-weak", target_vendor = "apple"))] pub mod weak; #[cfg(target_vendor = "apple")] #[link(name = "System", kind = "dylib")] extern "C" { pub fn __ulock_wait(op: u32, addr: *mut c_void, val: u64, micros: u32) -> c_int; pub fn __ulock_wake(op: u32, addr: *mut c_void, ...
code_fim
hard
{ "lang": "rust", "repo": "thomcc/ulock-sys", "path": "/src/lib.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|>// repo: legokichi/rust-sandbox path: /actix-sse/src/main.rs #[macro_use] extern crate log; extern crate env_logger; extern crate actix; extern crate actix_web; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate futures; #[macro_use] extern crate mdo; extern crate mdo_future; ...
code_fim
hard
{ "lang": "rust", "repo": "legokichi/rust-sandbox", "path": "/actix-sse/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { ::std::env::set_var("RUST_LOG", "info,actix_web=trace"); ::std::env::set_var("RUST_BACKTRACE", "full"); env_logger::init(); let sys = System::new("system"); let server = actix_web::server::new(||{ let handle = ::actix::Arbiter::handle(); let mut app = App::n...
code_fim
hard
{ "lang": "rust", "repo": "legokichi/rust-sandbox", "path": "/actix-sse/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(unused)] fn test04_lambdas() { } /// # fn main /// /// Main entry-point function. /// This is an example of documentation /// to items following it. /// /// You can open/test it with the command: /// `cargo doc --open` /// /// # Examples /// /// ``` /// let arg = 5; /// let answer = my_cr...
code_fim
medium
{ "lang": "rust", "repo": "ikarusx/rustilities", "path": "/main/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ikarusx/rustilities path: /main/src/main.rs //! # Main //! //! This is the entry point of the application, //! and this is an example for file documentation. //! It will document the file it is **in**, using *markdown*. /*! # Obs * This is another way to add multiline documentation/lists. * ...
code_fim
medium
{ "lang": "rust", "repo": "ikarusx/rustilities", "path": "/main/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Test assert_eq!(owning_user.into_string(), name.to_os_string().into_string()); // Teardown fs::remove_file("fourth.txt").expect("could not delete file"); } /* #[test] fn test_get_permissions() { // Setup let mut f = File::create("fifth.txt"...
code_fim
hard
{ "lang": "rust", "repo": "amyyq2/cs196", "path": "/Rust/section-one/plato/src/lib/file.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }