text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: 1u0/puzzles path: /advent-of-code-2019/day-5/src/main.rs
fn main() {
let code = intcode::load_code();
let outputs = intcode::r<|fim_suffix|>{:?}", outputs.last());
let outputs = intcode::run_code_with_inputs(code.to_vec(), vec![5]);
println!("Result for task 2: {:?}", outputs.la... | code_fim | medium | {
"lang": "rust",
"repo": "1u0/puzzles",
"path": "/advent-of-code-2019/day-5/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>to_vec(), vec![5]);
println!("Result for task 2: {:?}", outputs.last());
}<|fim_prefix|>// repo: 1u0/puzzles path: /advent-of-code-2019/day-5/src/main.rs
fn main() {
let code = intcode::load_code();
let outputs = intcode::run_code_with_inputs(code.to_vec(), vec![1]);
println!("Result for ... | code_fim | medium | {
"lang": "rust",
"repo": "1u0/puzzles",
"path": "/advent-of-code-2019/day-5/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let expected = r#"{}"#;
let data: Data = Default::default();
assert_eq!(expected, serde_json::to_string(&data).unwrap());
}<|fim_prefix|>// repo: jonasbb/serde_with path: /serde_with_macros/tests/serde_as_issue_538.rs
//! Check for the correct processing of ExprGroups in types
//!
//! They oc... | code_fim | medium | {
"lang": "rust",
"repo": "jonasbb/serde_with",
"path": "/serde_with_macros/tests/serde_as_issue_538.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonasbb/serde_with path: /serde_with_macros/tests/serde_as_issue_538.rs
//! Check for the correct processing of ExprGroups in types
//!
//! They occur when the types is passed in as a macro_rules argument like here.
//! https://github.com/jonasbb/serde_with/issues/538
macro_rules! t {
($($p... | code_fim | medium | {
"lang": "rust",
"repo": "jonasbb/serde_with",
"path": "/serde_with_macros/tests/serde_as_issue_538.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn t() {
let expected = r#"{}"#;
let data: Data = Default::default();
assert_eq!(expected, serde_json::to_string(&data).unwrap());
}<|fim_prefix|>// repo: jonasbb/serde_with path: /serde_with_macros/tests/serde_as_issue_538.rs
//! Check for the correct processing of ExprGroups in type... | code_fim | hard | {
"lang": "rust",
"repo": "jonasbb/serde_with",
"path": "/serde_with_macros/tests/serde_as_issue_538.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: justinrubek/reform path: /site/src/app/entry/view/mod.rs
use yew::prelude::*;
use yew::services::fetch::{FetchService, FetchTask, Response, Request};
use crate::api;
use crate::error::Error;
use crate::types::EntryInfo;
pub mod entry_item;
use entry_item::EntryItem;
pub struct ViewEntries {
... | code_fim | hard | {
"lang": "rust",
"repo": "justinrubek/reform",
"path": "/site/src/app/entry/view/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let block_id = Value::permanent(block_id);
let block_info = BlockInfo::new(block_id, parent_id, chain_length);
Ok(Some(block_info))
}
fn get_chain_length(&self, block_id: &[u8]) -> Result<Option<u32>, Error> {
let chain_length_bytes_slice = match self.block_id_ind... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/chain-libs",
"path": "/chain-storage/src/permanent_store.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: input-output-hk/chain-libs path: /chain-storage/src/permanent_store.rs
use crate::{BlockInfo, ConsistencyFailure, Error, Value};
use std::path::Path;
#[derive(Clone)]
pub(crate) struct PermanentStore {
blocks: data_pile::Database,
chain_length_index: data_pile::Database,
block_id_in... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/chain-libs",
"path": "/chain-storage/src/permanent_store.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Error, Debug)]
pub enum AuthenticateError {
#[error(transparent)]
Http(#[from] reqwest::Error),
#[error("the rate limit for the Hex API has been exceeded for this IP")]
RateLimited,
#[error("invalid username and password combination")]
InvalidCredentials,
#[error("a... | code_fim | hard | {
"lang": "rust",
"repo": "davidpdrsn/hexpm-rust",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Swift-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davidpdrsn/hexpm-rust path: /src/lib.rs
d::Signed, versions::Versions};
use async_trait::async_trait;
use bytes::buf::ext::BufExt;
use flate2::read::GzDecoder;
use lazy_static::lazy_static;
use regex::Regex;
use reqwest::StatusCode;
use serde::Deserialize;
use serde_json::json;
use std::collecti... | code_fim | hard | {
"lang": "rust",
"repo": "davidpdrsn/hexpm-rust",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Swift-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davidpdrsn/hexpm-rust path: /src/lib.rs
.http_client()
.post(self.api_base_url().join("keys").unwrap())
.basic_auth(username, Some(password))
.json(&body)
.send()
.await
.map_err(AuthenticateError::Http)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "davidpdrsn/hexpm-rust",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Swift-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rabisg0/rust-clippy path: /clippy_lints/src/loops.rs
,
pedantic,
"for-looping over `_.iter()` or `_.iter_mut()` when `&_` or `&mut _` would do"
}
declare_clippy_lint! {
/// **What it does:** Checks for loops on `y.into_iter()` where `y` will do, and
/// suggests the latter.
... | code_fim | hard | {
"lang": "rust",
"repo": "rabisg0/rust-clippy",
"path": "/clippy_lints/src/loops.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rabisg0/rust-clippy path: /clippy_lints/src/loops.rs
ks `for` loops over slices with an explicit counter
/// and suggests the use of `.enumerate()`.
///
/// **Why is it bad?** Using `.enumerate()` makes the intent more clear,
/// declutters the code and may be faster in some inst... | code_fim | hard | {
"lang": "rust",
"repo": "rabisg0/rust-clippy",
"path": "/clippy_lints/src/loops.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> NestedVisitorMap::None
}
}
/// Collects the set of variables in an expression
/// Stops analysis if a function call is found
/// Note: In some cases such as `self`, there are no mutable annotation,
/// All variables definition IDs are collected
struct VarCollectorVisitor<'a, 'tcx> {
cx: &... | code_fim | hard | {
"lang": "rust",
"repo": "rabisg0/rust-clippy",
"path": "/clippy_lints/src/loops.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: edgex004/rust-hdl path: /rust-hdl-pcb/src/traco_power_tmr1_series.rs
use std::collections::BTreeMap;
use std::fmt::{Display, Formatter};
use enum_iterator::IntoEnumIterator;
use rust_hdl_pcb_core::prelude::*;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum InputType {
Nominal05,
Nom... | code_fim | hard | {
"lang": "rust",
"repo": "edgex004/rust-hdl",
"path": "/rust-hdl-pcb/src/traco_power_tmr1_series.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn map_part_number_to_ordercode(part_number: &str) -> OrderCode {
for code in OrderCode::into_enum_iter() {
let code_name = format!("{:?}", code).replace("_", "-");
if code_name.eq(part_number) {
return code;
}
}
panic!("Unknown part number for TMR1 power su... | code_fim | hard | {
"lang": "rust",
"repo": "edgex004/rust-hdl",
"path": "/rust-hdl-pcb/src/traco_power_tmr1_series.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>-enabled (invalid) index in the SAP1 partition"]
#[inline]
pub fn sap1_1st_free_idx(&self) -> SAP1_1ST_FREE_IDXR {
let bits = {
const MASK: u8 = 255;
const OFFSET: u8 = 16;
((self.bits >> OFFSET) & MASK as u32) as u8
};
SAP1_1ST_FREE_IDXR... | code_fim | hard | {
"lang": "rust",
"repo": "therealprof/mkw41z",
"path": "/src/zll/sam_free_idx/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: therealprof/mkw41z path: /src/zll/sam_free_idx/mod.rs
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::SAM_FREE_IDX {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R {
bits: self.register.g... | code_fim | hard | {
"lang": "rust",
"repo": "therealprof/mkw41z",
"path": "/src/zll/sam_free_idx/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AngelOnFira/advent-of-code path: /2019/src/day6.rs
use std::collections::HashMap;
#[derive(Debug)]
struct Object<'a> {
parent: &'a str,
children: Vec<&'a str>,
}
#[aoc(day6, part1)]
pub fn solve_part1<'a>(input: &'a str) -> i32 {
let mut child_map: HashMap<&str, Object> = HashMap::... | code_fim | hard | {
"lang": "rust",
"repo": "AngelOnFira/advent-of-code",
"path": "/2019/src/day6.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while pointer != "unknown" {
pointer = child_map.get(pointer).unwrap().parent;
you_root.push(pointer);
}
pointer = "SAN";
while pointer != "unknown" {
pointer = child_map.get(pointer).unwrap().parent;
san_root.push(pointer);
}
for i in 0..you_root... | code_fim | hard | {
"lang": "rust",
"repo": "AngelOnFira/advent-of-code",
"path": "/2019/src/day6.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !child_map.contains_key(parent_name) {
child_map.insert(
parent_name,
Object {
parent: "unknown",
children: Vec::new(),
},
);
}
if !child_map.contains_key(child_name)... | code_fim | hard | {
"lang": "rust",
"repo": "AngelOnFira/advent-of-code",
"path": "/2019/src/day6.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>async fn get_command(message: UpdateWithCx<AutoSend<Bot>, Message>) {
let link = match db_manager::get_oldest_article(message.update.chat.id).await {
Some(x) => x,
None => String::from("You have no article to read in your storage\n¯\\_(ツ)_/¯ "),
};
message.answer(&link).send()... | code_fim | hard | {
"lang": "rust",
"repo": "toterGott/article-storage",
"path": "/src/dialog.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: toterGott/article-storage path: /src/dialog.rs
use std::fs;
use std::io::Read;
use extrablatt::Extrablatt;
use futures::StreamExt;
use teloxide::net::Download;
use teloxide::prelude::*;
use teloxide::prelude::*;
use teloxide::types::{Document, InlineKeyboardButton, InlineKeyboardMarkup, ReplyMa... | code_fim | hard | {
"lang": "rust",
"repo": "toterGott/article-storage",
"path": "/src/dialog.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// impl Handler<ClientCommand> for ChatClient {
// type Result = ();
// fn handle(&mut self, msg: ClientCommand, _: &mut Context<Self>) {
// let m = msg.0.trim();
// if m.starts_with('/') {
// let v: Vec<&str> = m.splitn(2, ' ').collect();
// match... | code_fim | hard | {
"lang": "rust",
"repo": "serbe/rsp",
"path": "/src/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: serbe/rsp path: /src/client.rs
// use std::net::SocketAddr;
// use std::str::FromStr;
// use std::time::Duration;
// use std::{io, process, thread};
// use actix::io::{FramedWrite, WriteHandler};
// use actix::{
// Actor, Arbiter, AsyncContext, Context, Handler, Message, Running, Str... | code_fim | hard | {
"lang": "rust",
"repo": "serbe/rsp",
"path": "/src/client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheHellBox/Penguins-Party path: /level_editor/src/components/drawable.rs
use crate::render::Color;
use specs::Component;
use specs::VecStorage;
use specs_derive::Component;
#[derive(Clone, Component)]
#[storage(VecStorage)]
pub struct Drawable {
pub sprite: String,
pub color: Color,
... | code_fim | medium | {
"lang": "rust",
"repo": "TheHellBox/Penguins-Party",
"path": "/level_editor/src/components/drawable.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
sprite: String::from("dev"),
uv_bounds: [1.0, 1.0],
uv_offset: [0.0, 0.0],
layer: 0,
color: Default::default(),
}
}
}<|fim_prefix|>// repo: TheHellBox/Penguins-Party path: /level_editor/src/components/drawable.rs
use c... | code_fim | medium | {
"lang": "rust",
"repo": "TheHellBox/Penguins-Party",
"path": "/level_editor/src/components/drawable.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> env_subst(stdin(), stdout()).unwrap();
}<|fim_prefix|>// repo: jeremybobbin/envsubst path: /src/main.rs
extern crate envsubst;
<|fim_middle|>use envsubst::env_subst;
use std::{
io::{
stdin,
stdout,
},
};
fn main() {
| code_fim | medium | {
"lang": "rust",
"repo": "jeremybobbin/envsubst",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeremybobbin/envsubst path: /src/main.rs
extern crate envsubst;
<|fim_suffix|>fn main() {
env_subst(stdin(), stdout()).unwrap();
}<|fim_middle|>use envsubst::env_subst;
use std::{
io::{
stdin,
stdout,
},
};
| code_fim | medium | {
"lang": "rust",
"repo": "jeremybobbin/envsubst",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: doy/ynab-reimbursements path: /src/ynab/client.rs
#[derive(Debug, snafu::Snafu)]
pub enum Error {
// ynab-api error types don't implement Error, so can't use the
// auto-source behavior
#[snafu(display("failed to update transactions: {}", source_msg))]
UpdateTransactions { source... | code_fim | hard | {
"lang": "rust",
"repo": "doy/ynab-reimbursements",
"path": "/src/ynab/client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct Client {
api: ynab_api::apis::client::APIClient,
}
impl Client {
pub fn new(key: &str) -> Self {
let mut ynab_config =
ynab_api::apis::configuration::Configuration::new();
ynab_config.api_key = Some(ynab_api::apis::configuration::ApiKey {
prefix:... | code_fim | hard | {
"lang": "rust",
"repo": "doy/ynab-reimbursements",
"path": "/src/ynab/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Feng-Jay/xv6-rust path: /kernel/src/fs/dinode.rs
use crate::define::fs::{ NDIRECT, DIRSIZ };
/// On-disk inode structure
#[repr(C)]
pub struct Dinode {
file_ty<|fim_suffix|>)
addrs: [usize;NDIRECT+1] // Data block addresses
}
pub struct Dirent {
inum: u16,
name:[u8;DIRSIZ]
}<|f... | code_fim | hard | {
"lang": "rust",
"repo": "Feng-Jay/xv6-rust",
"path": "/kernel/src/fs/dinode.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>)
addrs: [usize;NDIRECT+1] // Data block addresses
}
pub struct Dirent {
inum: u16,
name:[u8;DIRSIZ]
}<|fim_prefix|>// repo: Feng-Jay/xv6-rust path: /kernel/src/fs/dinode.rs
use crate::define::fs::{ NDIRECT, DIRSIZ };
/// On-disk inode structure
#[repr(C)]
pub struct Dinode {
file_type:... | code_fim | medium | {
"lang": "rust",
"repo": "Feng-Jay/xv6-rust",
"path": "/kernel/src/fs/dinode.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxcountryman/warp-api-starter-template path: /src/environment/argon.rs
use crate::Args;
#[derive(Clone, Debug)]
pub struct Argon {
secret: String,
memory_size: Option<u32>,
iterations: Option<u32>,
}
<|fim_suffix|> pub fn hasher(&self) -> argonautica::Hasher<'static> {
... | code_fim | hard | {
"lang": "rust",
"repo": "maxcountryman/warp-api-starter-template",
"path": "/src/environment/argon.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn hasher(&self) -> argonautica::Hasher<'static> {
let mut hasher = argonautica::Hasher::default();
let mut hasher = hasher.with_secret_key(&self.secret);
if let Some(memory_size) = self.memory_size {
hasher = hasher.configure_memory_size(memory_size);
}... | code_fim | hard | {
"lang": "rust",
"repo": "maxcountryman/warp-api-starter-template",
"path": "/src/environment/argon.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// New-type to own the type in the crate for conversions via From
pub struct CollectionSearchRequest<'a>(pub(crate) (CollectionId, &'a SearchRequest));
#[async_trait]
#[allow(unused_variables)]
impl ShardOperation for RemoteShard {
async fn update(
&self,
operation: CollectionUpdateOp... | code_fim | hard | {
"lang": "rust",
"repo": "qdrant/qdrant",
"path": "/lib/collection/src/shards/remote_shard.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result: Result<Vec<Record>, Status> = scroll_response
.result
.into_iter()
.map(|point| try_record_from_grpc(point, with_payload_interface.is_required()))
.collect();
result.map_err(|e| e.into())
}
async fn info(&self) -> Collec... | code_fim | hard | {
"lang": "rust",
"repo": "qdrant/qdrant",
"path": "/lib/collection/src/shards/remote_shard.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qdrant/qdrant path: /lib/collection/src/shards/remote_shard.rs
ess, |channel| {
let client = CollectionsInternalClient::new(channel);
let client = client.max_decoding_message_size(usize::MAX);
f(client)
})
.await
... | code_fim | hard | {
"lang": "rust",
"repo": "qdrant/qdrant",
"path": "/lib/collection/src/shards/remote_shard.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrewwhitehead/async-resource-rs path: /async-resource/src/pool/mod.rs
mod acquire;
pub use acquire::Acquire;
mod config;
pub use config::PoolConfig;
mod error;
pub use error::{AcquireError, ConfigError};
<|fim_suffix|>mod pool;
pub use pool::{Pool, PoolDrain};
mod wait;<|fim_middle|>mod op... | code_fim | easy | {
"lang": "rust",
"repo": "andrewwhitehead/async-resource-rs",
"path": "/async-resource/src/pool/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod pool;
pub use pool::{Pool, PoolDrain};
mod wait;<|fim_prefix|>// repo: andrewwhitehead/async-resource-rs path: /async-resource/src/pool/mod.rs
mod acquire;
pub use acquire::Acquire;
mod config;
pub use config::PoolConfig;
<|fim_middle|>mod error;
pub use error::{AcquireError, ConfigError};
mod op... | code_fim | medium | {
"lang": "rust",
"repo": "andrewwhitehead/async-resource-rs",
"path": "/async-resource/src/pool/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fridge-dev/frj-game-ngn path: /src/backend-engine/src/task/mod.rs
use crate::game_manager::api::{GameRepositoryClient, GameRepository};
use crate::game_manager::default_impl::DefaultGameRepository;
use crate::game_manager::types::GameIdentifier;
use crate::lost_cities_placeholder::LostCitiesEven... | code_fim | hard | {
"lang": "rust",
"repo": "fridge-dev/frj-game-ngn",
"path": "/src/backend-engine/src/task/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A 1:1 enumeration of GameRepository API methods.
#[derive(Debug)]
enum GameRepoTaskEvent {
// Non-game APIs
CleanupStaleGames,
// Pre-game APIs
CreatePregame(GameIdentifier),
RegisterPregameStream {
player_id: String,
game: GameIdentifier,
stream_out: Stream... | code_fim | hard | {
"lang": "rust",
"repo": "fridge-dev/frj-game-ngn",
"path": "/src/backend-engine/src/task/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// This is a mpsc Receiver wrapped around an instance of a GameRepository.
struct GameRepoTask<T: GameRepository> {
receiver: mpsc::UnboundedReceiver<GameRepoTaskEvent>,
game_repo: T,
}
impl GameRepoTask<DefaultGameRepository> {
pub fn new(receiver: mpsc::UnboundedReceiver<GameRepoTaskEvent>... | code_fim | hard | {
"lang": "rust",
"repo": "fridge-dev/frj-game-ngn",
"path": "/src/backend-engine/src/task/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonessouza/maratona-animeitor-rust path: /server/src/config.rs
use data::configdata::*;
// fn sede_from_value(v : Value) -> CResult<Sede> {
// let nome = v.get("nome").unwrap();
// let codigo = v.get("nome").unwrap();
// let premiacao = v.get("nome").unwrap().as_bool().unwrap();
// ... | code_fim | medium | {
"lang": "rust",
"repo": "jonessouza/maratona-animeitor-rust",
"path": "/server/src/config.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(config)
}
pub fn parse_config_teams(path: &std::path::Path) -> std::io::Result<ConfigTeams> {
let text = std::fs::read_to_string(path)?;
let config: ConfigTeams = toml::from_str(&text)?;
Ok(config)
}<|fim_prefix|>// repo: jonessouza/maratona-animeitor-rust path: /server/src/config.rs... | code_fim | hard | {
"lang": "rust",
"repo": "jonessouza/maratona-animeitor-rust",
"path": "/server/src/config.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for c in "Здравствуйте".chars() {
print!("{}", c);
}
}<|fim_prefix|>// repo: TahsinTariq/rust-notes path: /string_utf8/src/main.rs
#[allow(unused_variables)]
fn main() {
let data = "initial contents";
<|fim_middle|> let s = data.to_string();
// the method also works on a lit... | code_fim | medium | {
"lang": "rust",
"repo": "TahsinTariq/rust-notes",
"path": "/string_utf8/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TahsinTariq/rust-notes path: /string_utf8/src/main.rs
#[allow(unused_variables)]
fn main() {
<|fim_suffix|> let s = data.to_string();
// the method also works on a literal directly:
let s = "initial contents".to_string();
println!("{}", s);
for c in "Здравствуйте".chars() {... | code_fim | easy | {
"lang": "rust",
"repo": "TahsinTariq/rust-notes",
"path": "/string_utf8/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // the method also works on a literal directly:
let s = "initial contents".to_string();
println!("{}", s);
for c in "Здравствуйте".chars() {
print!("{}", c);
}
}<|fim_prefix|>// repo: TahsinTariq/rust-notes path: /string_utf8/src/main.rs
#[allow(unused_variables)]
fn main() ... | code_fim | easy | {
"lang": "rust",
"repo": "TahsinTariq/rust-notes",
"path": "/string_utf8/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Default)]
pub struct Metrics {
pub spans: Vec<Row>,
pub total_lines: usize,
}
#[derive(Debug, Clone, Default)]
pub struct Row {
pub start: Location,
pub end: Location,
pub num_lines: usize,
}
#[derive(Debug, Clone, Default)]
pub struct Location {
pub filena... | code_fim | hard | {
"lang": "rust",
"repo": "Michael-F-Bryan/cargo-metrics",
"path": "/src/unsafe_visitor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Michael-F-Bryan/cargo-metrics path: /src/unsafe_visitor.rs
use syntax::codemap::CodeMap;
use syntax::ast::{Block, BlockCheckMode, Crate, Item, ItemKind, Mac, Unsafety};
use syntax::visit::{self, Visitor};
use syntax_pos::Loc;
use syntax::ext::quote::rt::Span;
pub fn analyse_ast(ast: &Crate, co... | code_fim | hard | {
"lang": "rust",
"repo": "Michael-F-Bryan/cargo-metrics",
"path": "/src/unsafe_visitor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let BlockCheckMode::Unsafe(_) = block.rules {
self.unsafe_lines.push(block.span.clone());
}
visit::walk_block(self, block);
}
fn visit_mac(&mut self, _: &'a Mac) {}
}
#[derive(Debug, Clone, Default)]
pub struct Metrics {
pub spans: Vec<Row>,
pub t... | code_fim | hard | {
"lang": "rust",
"repo": "Michael-F-Bryan/cargo-metrics",
"path": "/src/unsafe_visitor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: strymon-system/strymon-core path: /src/strymon_job/src/publisher/sink.rs
// Copyright 2018 ETH Zurich. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensour... | code_fim | medium | {
"lang": "rust",
"repo": "strymon-system/strymon-core",
"path": "/src/strymon_job/src/publisher/sink.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.tx.unbounded_send(event).unwrap();
}
}
/// A asynchronous `Stream` receiving Timely events put into the corresponding
/// sink.
pub struct EventStream<T, D> {
rx: mpsc::UnboundedReceiver<Event<T, D>>,
}
impl<T, D> Stream for EventStream<T, D> {
type Item = Event<T, D>;
type ... | code_fim | hard | {
"lang": "rust",
"repo": "strymon-system/strymon-core",
"path": "/src/strymon_job/src/publisher/sink.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A asynchronous `Stream` receiving Timely events put into the corresponding
/// sink.
pub struct EventStream<T, D> {
rx: mpsc::UnboundedReceiver<Event<T, D>>,
}
impl<T, D> Stream for EventStream<T, D> {
type Item = Event<T, D>;
type Error = ();
fn poll(&mut self) -> Poll<Option<Event<... | code_fim | medium | {
"lang": "rust",
"repo": "strymon-system/strymon-core",
"path": "/src/strymon_job/src/publisher/sink.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[deriving(Eq)]
pub struct SDL_Point {
pub x: c_int,
pub y: c_int,
}
#[deriving(Eq)]
pub struct SDL_Rect {
pub x: c_int,
pub y: c_int,
pub w: c_int,
pub h: c_int,
}
#[inline]
pub fn SDL_RectEmpty(r: &SDL_Rect) -> SDL_bool {
if (r.w <= 0) || (r.h <= 0) { SDL_TRUE } else { SDL_... | code_fim | medium | {
"lang": "rust",
"repo": "pakoito/sdl2-rs",
"path": "/src/sdl2/ffi/rect.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pakoito/sdl2-rs path: /src/sdl2/ffi/rect.rs
// Copyright 2014 The sdl2-rs Developers.
//
// 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.o... | code_fim | medium | {
"lang": "rust",
"repo": "pakoito/sdl2-rs",
"path": "/src/sdl2/ffi/rect.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>extern "C" {
pub fn SDL_HasIntersection(A: *SDL_Rect, B: *SDL_Rect) -> SDL_bool;
pub fn SDL_IntersectRect(A: *SDL_Rect, B: *SDL_Rect, result: *mut SDL_Rect) -> SDL_bool;
pub fn SDL_UnionRect(A: *SDL_Rect, B: *SDL_Rect, result: *mut SDL_Rect);
pub fn SDL_EnclosePoints(points: *SDL_Point, co... | code_fim | medium | {
"lang": "rust",
"repo": "pakoito/sdl2-rs",
"path": "/src/sdl2/ffi/rect.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lukaslueg/built path: /example_project/src/main.rs
// The file `built.rs` was placed there by cargo and `build.rs`
mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}
fn main() {
// Print various information produced by `built`. See the docs for a full list.
println... | code_fim | hard | {
"lang": "rust",
"repo": "lukaslueg/built",
"path": "/example_project/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print!(
"I was built for a {}-CPU, which is a {}-endian architecture. ",
built_info::CFG_TARGET_ARCH,
built_info::CFG_ENDIAN
);
println!(
"I was compiled to run on {} (a {}-breed) and my runtime should be {}.\n",
built_info::CFG_OS,
built_info::... | code_fim | hard | {
"lang": "rust",
"repo": "lukaslueg/built",
"path": "/example_project/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match built_info::CI_PLATFORM {
None => print!("It seems I've not been built on a continuous integration platform,"),
Some(ci) => print!("I've been built on CI-platform {ci},"),
}
if built::util::detect_ci().is_some() {
println!(" but I'm currently executing on one!\n")... | code_fim | hard | {
"lang": "rust",
"repo": "lukaslueg/built",
"path": "/example_project/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jamiepg1/ncollide path: /src/procedural/to_polyline/cylinder_to_polyline.rs
use std::num::Zero;
use nalgebra::na::Vec2;
use nalgebra::na;
use geom::Cylinder;
use procedural::{Polyline, ToPolyline};
use procedural;
use math::{Scalar, Vect};
<|fim_suffix|> procedural::rectangle(&Vec2::new(... | code_fim | medium | {
"lang": "rust",
"repo": "jamiepg1/ncollide",
"path": "/src/procedural/to_polyline/cylinder_to_polyline.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _2: Scalar = na::cast(2.0f64);
procedural::rectangle(&Vec2::new(self.radius() * _2, self.half_height() * _2))
}
}<|fim_prefix|>// repo: jamiepg1/ncollide path: /src/procedural/to_polyline/cylinder_to_polyline.rs
use std::num::Zero;
use nalgebra::na::Vec2;
use nalgebra::na;
use ge... | code_fim | medium | {
"lang": "rust",
"repo": "jamiepg1/ncollide",
"path": "/src/procedural/to_polyline/cylinder_to_polyline.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl PendingPost {
fn approve(mut self) -> Posts { //same reason - we're actually MOVING content, so takes just "self", without &
self.approvals += 1;
if self.approvals >= 2 { //ready post
Posts::RP(ReadyPost {
content: self.content,
})
}... | code_fim | hard | {
"lang": "rust",
"repo": "ilmoi/rust_learnings",
"path": "/stdlib/src/traits_trait_objects/ch17_3b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ilmoi/rust_learnings path: /stdlib/src/traits_trait_objects/ch17_3b.rs
fn main() {
let mut post = Post::new();
post.add_text("I ate a salad for lunch today");
let post = post.request_review();
let post = post.approve(); //pending post
let second_post;
if let Posts::PP(... | code_fim | hard | {
"lang": "rust",
"repo": "ilmoi/rust_learnings",
"path": "/stdlib/src/traits_trait_objects/ch17_3b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ReadyPost {
pub fn content(&self) -> &str {
&self.content
}
}
// -----------------------------------------------------------------------------
// trait
//testing what implementing a trait on all would look like
trait GetContent {
fn content2(&self) -> &str; //can't have &self.co... | code_fim | hard | {
"lang": "rust",
"repo": "ilmoi/rust_learnings",
"path": "/stdlib/src/traits_trait_objects/ch17_3b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fatalbanana/stegos path: /network/src/delivery/protocol.rs
//
// MIT License
//
// Copyright (c) 2019 Stegos AG
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software w... | code_fim | hard | {
"lang": "rust",
"repo": "fatalbanana/stegos",
"path": "/network/src/delivery/protocol.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let msg_server = msg.clone();
let msg_client = msg.clone();
let listener = TcpListener::bind(&"127.0.0.1:0".parse().unwrap()).unwrap();
let listener_addr = listener.local_addr().unwrap();
let server = listener
.incoming()
.into_future()
... | code_fim | hard | {
"lang": "rust",
"repo": "fatalbanana/stegos",
"path": "/network/src/delivery/protocol.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for d in file_descriptor_proto_array {
if d.get_name() == "ext.proto" {
// print extension info
let ext_extension_info = d.get_extension();
extension_info.append(&mut ext_extension_info.to_owned());
println!("*****ext info*****");
pri... | code_fim | hard | {
"lang": "rust",
"repo": "cita-cloud/controller_builder",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cita-cloud/controller_builder path: /src/main.rs
//mod prost_warpper;
use protobuf::{Message, UnknownValues};
use protobuf::descriptor::{FieldDescriptorProto, FieldDescriptorProto_Type, FileDescriptorSet};
use protobuf::types::{ProtobufTypeDouble, ProtobufType, ProtobufTypeFloat, ProtobufTypeIn... | code_fim | hard | {
"lang": "rust",
"repo": "cita-cloud/controller_builder",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut extension_info = Vec::new();
for d in file_descriptor_proto_array {
if d.get_name() == "ext.proto" {
// print extension info
let ext_extension_info = d.get_extension();
extension_info.append(&mut ext_extension_info.to_owned());
print... | code_fim | hard | {
"lang": "rust",
"repo": "cita-cloud/controller_builder",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: amindWalker/marvel-collection path: /app/src/types/comics.rs
// External depencendies
use serde::{self, Deserialize, Serialize};
// Local depencendies
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ComicsRoot {
pub code: i64... | code_fim | hard | {
"lang": "rust",
"repo": "amindWalker/marvel-collection",
"path": "/app/src/types/comics.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tolidano/ALVR path: /alvr/server/src/lib.rs
mod connection;
mod connection_utils;
mod logging_backend;
mod openvr;
mod web_server;
#[allow(non_camel_case_types, non_upper_case_globals, dead_code)]
mod bindings {
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
}
use bindings::*;
use alv... | code_fim | hard | {
"lang": "rust",
"repo": "tolidano/ALVR",
"path": "/alvr/server/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn init() {
let (log_sender, _) = broadcast::channel(web_server::WS_BROADCAST_CAPACITY);
let (events_sender, _) = broadcast::channel(web_server::WS_BROADCAST_CAPACITY);
logging_backend::init_logging(log_sender.clone(), events_sender.clone());
if let Some(runtime) = MAYBE_RUNTIME.lock().as... | code_fim | hard | {
"lang": "rust",
"repo": "tolidano/ALVR",
"path": "/alvr/server/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let args = Cli::from_args();
env_logger::builder()
.format(|buf, record| {
writeln!(
buf,
"[{} {:5} {}] ({}:{}) {}",
Local::now().format("%+"),
buf.default_styled_level(record.level()),
record.targe... | code_fim | medium | {
"lang": "rust",
"repo": "colelawrence/webbundle",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: colelawrence/webbundle path: /src/main.rs
// Copyright 2020 Google 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.apache.org/licenses/LI... | code_fim | medium | {
"lang": "rust",
"repo": "colelawrence/webbundle",
"path": "/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() -> Result<()> {
let args = Cli::from_args();
env_logger::builder()
.format(|buf, record| {
writeln!(
buf,
"[{} {:5} {}] ({}:{}) {}",
Local::now().format("%+"),
buf.default_styled_level(record.level()),
... | code_fim | hard | {
"lang": "rust",
"repo": "colelawrence/webbundle",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: simonsan/ac-trainer path: /src/entities.rs
use crate::proc::{self, Read};
pub struct Player {
pub x: f32,
pub y: f32,
pub z: f32,
pub health: i32,
pub armor: i32,
pub name: String,
}
pub const PLAYER_X_OFFSET: isize = 0x4;
pub const PLAYER_Y_OFFSET: isize = 0x8;
pub con... | code_fim | hard | {
"lang": "rust",
"repo": "simonsan/ac-trainer",
"path": "/src/entities.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let name_bytes = proc::read(handle, addr + PLAYER_NAME_OFFSET as u32, PLAYER_NAME_SIZE)?
.iter()
.take_while(|&c| *c != 0)
.copied()
.collect::<Vec<u8>>();
let name = String::from_utf8(name_bytes)
.map_err(|_| String::from("inval... | code_fim | hard | {
"lang": "rust",
"repo": "simonsan/ac-trainer",
"path": "/src/entities.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match event {
Event::MouseDown(ref mouse) if mouse.button.is_right() => {
let menu = ContextMenu::new(make_context_menu::<AppState>(), mouse.pos);
ctx.show_context_menu(menu);
}
_ => child.event(ctx, event, data, env),
}
... | code_fim | hard | {
"lang": "rust",
"repo": "futurepaul/tile-wave",
"path": "/src/controllers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: futurepaul/tile-wave path: /src/controllers.rs
use druid::{
widget::Controller, ContextMenu, Data, Env, Event, EventCtx, LocalizedString, MenuDesc,
MenuItem, Widget,
};
use crate::data::{AppState, CLEAR_CANVAS, SAVE_CANVAS, SHOW_MAP_WINDOW};
pub struct ContextMenuController;
impl<T, W... | code_fim | medium | {
"lang": "rust",
"repo": "futurepaul/tile-wave",
"path": "/src/controllers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let sender = rpc_sender;
let runtime_handle = self.runtime_handle.clone();
let connection = self.connection.clone();
let subscription = nats_connection
.subscribe(&topic)
.await
.map_err(Error::Nats)?;
self.runtime_handle.spawn(... | code_fim | hard | {
"lang": "rust",
"repo": "tfgco/pitaya-rs",
"path": "/src/pitaya_etcd_nats_cluster/src/rpc_server.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tfgco/pitaya-rs path: /src/pitaya_etcd_nats_cluster/src/rpc_server.rs
use crate::settings;
use async_trait::async_trait;
use futures::{future, StreamExt};
use nats::{self, asynk};
use pitaya_core::{
cluster::{Error, Rpc, RpcServer, ServerInfo},
metrics::{self},
protos, utils,
};
use ... | code_fim | hard | {
"lang": "rust",
"repo": "tfgco/pitaya-rs",
"path": "/src/pitaya_etcd_nats_cluster/src/rpc_server.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wotsushi/competitive-programming path: /agc/039/a.rs
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]
fn main() {
let S: Vec<char> = {
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().chars().... | code_fim | hard | {
"lang": "rust",
"repo": "wotsushi/competitive-programming",
"path": "/agc/039/a.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>es + 1, '-') } else { (res, S[i]) });
l / 2 + m * K + (l + r) / 2 * (K - 1) + r / 2
} else {
let (m, _) = (0..N).fold((0, '-'), |(res, prev), i| if S[i] == prev { (res + 1, '-') } else { (res, S[i]) });
m * K
};
println!("{}", ans);
}<|fim_prefix|>// repo: wotsushi/com... | code_fim | hard | {
"lang": "rust",
"repo": "wotsushi/competitive-programming",
"path": "/agc/039/a.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>K / 2
} else if S[0] == S[N - 1] {
let c = S[0];
let l = (0..N).take_while(|&i| S[i] == c).count();
let r = (0..N).rev().take_while(|&i| S[i] == c).count();
let (m, _) = (l..(N - r)).fold((0, '-'), |(res, prev), i| if S[i] == prev { (res + 1, '-') } else { (res, S[i]) }... | code_fim | hard | {
"lang": "rust",
"repo": "wotsushi/competitive-programming",
"path": "/agc/039/a.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dancojocaru2000/rust-c_wrapper path: /src/chdir.rs
use std::ffi::CString;
use crate::{c_error::CError, c_result::CResult};
pub fn chdir<P<|fim_suffix|>o()),
bad_return => panic!(format!("Unknown return from access: {}", bad_return)),
}
}<|fim_middle|>ath: Into<CString>>(path: Path) -> CResu... | code_fim | medium | {
"lang": "rust",
"repo": "dancojocaru2000/rust-c_wrapper",
"path": "/src/chdir.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>o()),
bad_return => panic!(format!("Unknown return from access: {}", bad_return)),
}
}<|fim_prefix|>// repo: dancojocaru2000/rust-c_wrapper path: /src/chdir.rs
use std::ffi::CString;
use crate::{c_error::CError, c_result::CResult};
pub fn chdir<P<|fim_middle|>ath: Into<CString>>(path: Path) -> CResu... | code_fim | medium | {
"lang": "rust",
"repo": "dancojocaru2000/rust-c_wrapper",
"path": "/src/chdir.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // To avoid the IO failure being ignored silently, we manually call the present function
root.present().expect("Unable to write result to file, please make sure 'plotters-doc-data' dir exists under current dir");
println!("Result has been saved to {}", OUT_FILE_NAME);
Ok(())
}
#[test]
fn e... | code_fim | medium | {
"lang": "rust",
"repo": "plotters-rs/plotters",
"path": "/plotters/examples/area-chart.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: plotters-rs/plotters path: /plotters/examples/area-chart.rs
use plotters::prelude::*;
use rand::SeedableRng;
use rand_distr::{Distribution, Normal};
use rand_xorshift::XorShiftRng;
const OUT_FILE_NAME: &'static str = "plotters-doc-data/area-chart.png";
fn main() -> Result<(), Box<dyn std::erro... | code_fim | hard | {
"lang": "rust",
"repo": "plotters-rs/plotters",
"path": "/plotters/examples/area-chart.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SmithCodez/abcd path: /packages/loopswap/src/pair.rs
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::asset::{Asset, AssetInfo};
use cosmwasm_std::{Decimal, Uint128};
use cw20::Cw20ReceiveMsg;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "SmithCodez/abcd",
"path": "/packages/loopswap/src/pair.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// ReverseSimulationResponse returns reverse swap simulation response
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct ReverseSimulationResponse {
pub offer_amount: Uint128,
pub spread_amount: Uint128,
pub commission_amount: Uint128,
}
/// We currently take n... | code_fim | hard | {
"lang": "rust",
"repo": "SmithCodez/abcd",
"path": "/packages/loopswap/src/pair.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// SimulationResponse returns swap simulation response
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct SimulationResponse {
pub return_amount: Uint128,
pub spread_amount: Uint128,
pub commission_amount: Uint128,
pub reward_stake_amount:Uint128,
}
/// Rev... | code_fim | hard | {
"lang": "rust",
"repo": "SmithCodez/abcd",
"path": "/packages/loopswap/src/pair.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vtavernier/tinygl path: /tinygl/src/wrappers/shader/binary_shader.rs
use crate::Context;
use super::{make_shader, ShaderCommon};
pub fn build_bin_shader(
gl: &Context,
binary: &[u8],
kind: u32,
) -> crate::Result<crate::gl::Shader> {
unsafe {
make_shader(gl, kind, |shad... | code_fim | hard | {
"lang": "rust",
"repo": "vtavernier/tinygl",
"path": "/tinygl/src/wrappers/shader/binary_shader.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn build(gl: &Context, kind: u32) -> crate::Result<crate::gl::Shader> {
build_bin_shader(gl, Self::get_binary(), kind)
}
}<|fim_prefix|>// repo: vtavernier/tinygl path: /tinygl/src/wrappers/shader/binary_shader.rs
use crate::Context;
use super::{make_shader, ShaderCommon};
pub fn build_... | code_fim | hard | {
"lang": "rust",
"repo": "vtavernier/tinygl",
"path": "/tinygl/src/wrappers/shader/binary_shader.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fyang93/rust-leetcode path: /src/p0096_unique_binary_search_trees.rs
pub fn num_trees(n: i32) -> i32 {
let mut nums = vec![1; n as usize + 1];
for i in 2..=n as usize {
nums[i] = (0..i).fold(0, |sum, j| sum + nums[j] * nums[i - j - 1]);
}
nums[n as usize]
}
#[cfg(test)... | code_fim | easy | {
"lang": "rust",
"repo": "fyang93/rust-leetcode",
"path": "/src/p0096_unique_binary_search_trees.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn it_works() {
assert_eq!(num_trees(3), 5);
}
}<|fim_prefix|>// repo: fyang93/rust-leetcode path: /src/p0096_unique_binary_search_trees.rs
pub fn num_trees(n: i32) -> i32 {
let mut nums = vec![1; n as usize + 1];
<|fim_middle|> for i in 2..=n as usize {
nums[i... | code_fim | medium | {
"lang": "rust",
"repo": "fyang93/rust-leetcode",
"path": "/src/p0096_unique_binary_search_trees.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>by, order_by_multi},
showindexes::showindexes,
value::value,
};<|fim_prefix|>// repo: maxtnuk/gluesql path: /test-suite/src/index/mod.rs
mod and;
mod basic;
mod expr;
mod nested;
mod null;
mod order_by;
mod showindexes;
mod value;
pub use {
and::and,
basic::basic,
<|fim_middle|> expr:... | code_fim | medium | {
"lang": "rust",
"repo": "maxtnuk/gluesql",
"path": "/test-suite/src/index/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maxtnuk/gluesql path: /test-suite/src/index/mod.rs
mod and;
mod basic;
mod expr;
mod nested;
mod null;
mod order_by;
mod <|fim_suffix|> expr::expr,
nested::nested,
null::null,
order_by::{order_by, order_by_multi},
showindexes::showindexes,
value::value,
};<|fim_middle|>showin... | code_fim | medium | {
"lang": "rust",
"repo": "maxtnuk/gluesql",
"path": "/test-suite/src/index/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AstTranslator {
pub(crate) fn numeric_constant(
ast_numeric_constant: apllodb_ast::NumericConstant,
) -> ApllodbResult<SqlValue> {
let sql_value: SqlValue = match ast_numeric_constant {
apllodb_ast::NumericConstant::IntegerConstantVariant(ic) => Self::integer_const... | code_fim | medium | {
"lang": "rust",
"repo": "apllodb/apllodb",
"path": "/apllodb-sql-processor/src/ast_translator/expression/constant/numeric_constant.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apllodb/apllodb path: /apllodb-sql-processor/src/ast_translator/expression/constant/numeric_constant.rs
pub(crate) mod integer_constant;
use apllodb_shared_components::{ApllodbResult, SqlValue};
use apllodb_sql_parser::apllodb_ast;
<|fim_suffix|>impl AstTranslator {
pub(crate) fn numeric_c... | code_fim | medium | {
"lang": "rust",
"repo": "apllodb/apllodb",
"path": "/apllodb-sql-processor/src/ast_translator/expression/constant/numeric_constant.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.