text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: hbeimf/thrift_demo path: /thrift0.11.0/rust_thrift_demo/src/bin/client.rs
extern crate thrift;
extern crate example;
use thrift::protocol::{TCompactInputProtocol, TCompactOutputProtocol};
use thrift::transport::{TFramedReadTransport, TFramedWriteTransport, TIoChannel, TTcpChannel};
use std::ti... | code_fim | medium | {
"lang": "rust",
"repo": "hbeimf/thrift_demo",
"path": "/thrift0.11.0/rust_thrift_demo/src/bin/client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone)]
pub struct WorldGravity(pub Vector3<f32>);
#[derive(Debug, Clone)]
pub struct WorldTerminalVelocity(pub Vector3<f32>);<|fim_prefix|>// repo: olefasting/amethyst_2d_platformer path: /src/resources/mod.rs
use amethyst::{core::math::Vector3, ecs::Entity};
#[derive(Debug, Clone)]
pu... | code_fim | medium | {
"lang": "rust",
"repo": "olefasting/amethyst_2d_platformer",
"path": "/src/resources/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone)]
pub struct WorldTerminalVelocity(pub Vector3<f32>);<|fim_prefix|>// repo: olefasting/amethyst_2d_platformer path: /src/resources/mod.rs
use amethyst::{core::math::Vector3, ecs::Entity};
<|fim_middle|>#[derive(Debug, Clone)]
pub enum StateId {
None,
GameplayState,
}
impl Defa... | code_fim | hard | {
"lang": "rust",
"repo": "olefasting/amethyst_2d_platformer",
"path": "/src/resources/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: olefasting/amethyst_2d_platformer path: /src/resources/mod.rs
use amethyst::{core::math::Vector3, ecs::Entity};
<|fim_suffix|>#[derive(Debug, Clone)]
pub struct WorldTerminalVelocity(pub Vector3<f32>);<|fim_middle|>#[derive(Debug, Clone)]
pub enum StateId {
None,
GameplayState,
}
impl Defa... | code_fim | hard | {
"lang": "rust",
"repo": "olefasting/amethyst_2d_platformer",
"path": "/src/resources/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Potato-Gaming/crystal path: /league-client/src/models/leagues_lcds_league_item_dto.rs
/*
*
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
* Generated by: https://openapi-gene... | code_fim | hard | {
"lang": "rust",
"repo": "Potato-Gaming/crystal",
"path": "/league-client/src/models/leagues_lcds_league_item_dto.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>none")]
pub queue_type: Option<String>,
#[serde(rename = "rank", skip_serializing_if = "Option::is_none")]
pub rank: Option<String>,
#[serde(rename = "tier", skip_serializing_if = "Option::is_none")]
pub tier: Option<String>,
#[serde(rename = "timeUntilInactivityStatusChanges", ski... | code_fim | hard | {
"lang": "rust",
"repo": "Potato-Gaming/crystal",
"path": "/league-client/src/models/leagues_lcds_league_item_dto.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let password = "a".repeat(MAX_PAM_RESPONSE_SIZE - 1 /* null byte */);
let env = Env("ALL ALL=(ALL:ALL) ALL")
.user(User(USERNAME).password(password))
.build()?;
let input_sizes = [MAX_PAM_RESPONSE_SIZE, MAX_PAM_RESPONSE_SIZE + 1];
for input_size in input_sizes {
l... | code_fim | hard | {
"lang": "rust",
"repo": "memorysafety/sudo-rs",
"path": "/test-framework/sudo-compliance-tests/src/sudo/pass_auth/stdin.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn input_longer_than_max_pam_response_size_is_handled_gracefully() -> Result<()> {
let env = Env("ALL ALL=(ALL:ALL) ALL").user(USERNAME).build()?;
let input = "a".repeat(5 * MAX_PAM_RESPONSE_SIZE / 2);
let output = Command::new("sudo")
.args(["-S", "true"])
.stdin(inpu... | code_fim | hard | {
"lang": "rust",
"repo": "memorysafety/sudo-rs",
"path": "/test-framework/sudo-compliance-tests/src/sudo/pass_auth/stdin.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: memorysafety/sudo-rs path: /test-framework/sudo-compliance-tests/src/sudo/pass_auth/stdin.rs
use pretty_assertions::assert_eq;
use sudo_test::{Command, Env, User};
use crate::{Result, PASSWORD, USERNAME};
use super::MAX_PAM_RESPONSE_SIZE;
#[test]
fn correct_password() -> Result<()> {
let ... | code_fim | hard | {
"lang": "rust",
"repo": "memorysafety/sudo-rs",
"path": "/test-framework/sudo-compliance-tests/src/sudo/pass_auth/stdin.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jiegec/verilog-lang path: /src/ast/declarations/declaration_ranges.rs
//! A.2.5 Declaration ranges
use crate::ast::*;
/// packed_dimension ::= [ constant_range ] | unsized_dimension
/// unsized_dimension ::= [ ]
/// constant_range ::= constant_expression : constant_expression
/// constant_expr... | code_fim | hard | {
"lang": "rust",
"repo": "jiegec/verilog-lang",
"path": "/src/ast/declarations/declaration_ranges.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Parse for UnpackedDimension {
fn parse(parser: &mut Parser<'_>) -> Option<Self> {
if parser.probe_err(&[Token::LBracket]) {
parser.advance();
if parser.probe(&[Token::Number]) {
let mut res = Self::default();
res.from = Number::parse... | code_fim | hard | {
"lang": "rust",
"repo": "jiegec/verilog-lang",
"path": "/src/ast/declarations/declaration_ranges.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
/// Test the equality between two TNetString values
impl cmp::Eq for TNetString {
fn eq(&self, other: &TNetString) -> bool {
match (self, other) {
(&Str(ref s0), &Str(ref s1)) => s0 == s1,
(&Int(i0), &Int(i1)) => i0 == i1,
(&Float(f0), &Float(f1)) => f0 =... | code_fim | hard | {
"lang": "rust",
"repo": "smvv/rust-tnetstring",
"path": "/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match reader.read_byte() as char {
'#' => {
let s = unsafe { str::raw::from_bytes(payload) };
int::from_str(s).map(|v| Int(*v))
}
'}' => Some(Map(parse_map(payload))),
']' => Some(Vec(parse_vec(payload))),
'!' => {
let s = unsafe { str::raw::from_b... | code_fim | hard | {
"lang": "rust",
"repo": "smvv/rust-tnetstring",
"path": "/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: smvv/rust-tnetstring path: /lib.rs
#[link(name = "tnetstring",
vers = "0.3",
uuid = "ce93b70c-c22a-45fa-97a7-66ab97009005")];
#[crate_type = "lib"];
/// Rust TNetStrings serialization library.
use std::{cmp, float, int, io, str, to_str};
/// Represents a TNetString value.
pub en... | code_fim | hard | {
"lang": "rust",
"repo": "smvv/rust-tnetstring",
"path": "/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
// note that the first arg is always the name of runfile
let args: Vec<String> = env::args().collect();
let config = Config::new(&args).unwrap_or_else(|err|{
eprintln!("Problem parsing arguments: {}", err);
process::exit(1);
});
if let Err(e) = run(config)... | code_fim | medium | {
"lang": "rust",
"repo": "joseph-zhang/PL-stove",
"path": "/TRPL/grep/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joseph-zhang/PL-stove path: /TRPL/grep/src/main.rs
// a simple IO project like grep
// to search a given string in the file
extern crate grep;
<|fim_suffix|> // note that the first arg is always the name of runfile
let args: Vec<String> = env::args().collect();
let config = Config::... | code_fim | medium | {
"lang": "rust",
"repo": "joseph-zhang/PL-stove",
"path": "/TRPL/grep/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn read_as_bytes(opts: &mut Opts) -> (Option<Vec<u8>>, Vec<Words>) {
let mut stdin = stdin();
let mut indent: Option<Vec<u8>> = None;
let mut lines = Vec::new();
while let Ok(line) = stdin.read_until(b'\n') {
if indent.is_none() {
let tmp = line.iter().map(|c| *c).take_... | code_fim | hard | {
"lang": "rust",
"repo": "mahkoh/align-rust",
"path": "/align.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> WordIter {
pos: 0,
line: &self.line,
words: &self.words,
}
}
}
struct WordIter<'a> {
pos: uint,
line: &'a Vec<u8>,
words: &'a Vec<(uint, uint)>,
}
impl<'a> Iterator<&'a [u8]> for WordIter<'a> {
fn next(&mut self) -> Option<&'a [u8]>... | code_fim | hard | {
"lang": "rust",
"repo": "mahkoh/align-rust",
"path": "/align.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mahkoh/align-rust path: /align.rs
#![feature(slicing_syntax, macro_rules)]
#![allow(unused_must_use)]
extern crate getopts;
use std::io::{stdin, stderr, BufferedWriter};
use std::io::stdio::{stdout_raw};
use std::os::{args, set_exit_status};
use std::{uint, str};
use getopts::{getopts, optopt,... | code_fim | hard | {
"lang": "rust",
"repo": "mahkoh/align-rust",
"path": "/align.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn propagate_derived_from(&mut self) {
for i in 0..self.peripherals.len() {
while self.peripherals[i].derived_from.is_some() {
let mut peripheral_derived_from = None;
if let Some(ref derived_from) = self.peripherals[i].derived_from {
... | code_fim | hard | {
"lang": "rust",
"repo": "dzamlo/svd",
"path": "/src/device.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dzamlo/svd path: /src/device.rs
use cpu::Cpu;
use errors::*;
use interrupt::Interrupt;
use peripheral::Peripheral;
use register_properties_group::RegisterPropertiesGroup;
use std::collections::HashMap;
use std::io::Read;
use types::*;
use utils::get_child_text;
use xmltree;
pub type Peripherals... | code_fim | hard | {
"lang": "rust",
"repo": "dzamlo/svd",
"path": "/src/device.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, T> Matrix for Row<'a, T> {
type Elem = T;
fn ncols(&self) -> u32 {
self.len()
}
fn nrows(&self) -> u32 {
1
}
}
impl<'a, T> Matrix for RowMut<'a, T> {
type Elem = T;
fn ncols(&self) -> u32 {
self.len()
}
fn nrows(&self) -> u32 {
... | code_fim | hard | {
"lang": "rust",
"repo": "japaric-archived/linalg.rs",
"path": "/src/linear.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// IntoIterator
macro_rules! into_iter {
($ty:ident, $ty_mut:ident, $ty_owned:ident) => {
impl<'a, T> IntoIterator for &'a $ty_owned<T> {
type IntoIter = slice::Iter<'a, T>;
type Item = &'a T;
fn into_iter(self) -> slice::Iter<'a, T> {
self.... | code_fim | hard | {
"lang": "rust",
"repo": "japaric-archived/linalg.rs",
"path": "/src/linear.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: japaric-archived/linalg.rs path: /src/linear.rs
ce, SliceMut, Transpose};
use {Col, ColMut, ColVec, Diag, DiagMut, Row, RowMut, RowVec, Tor};
impl<'a, T> Col<'a, T> {
/// Returns a slice that contains the whole vector
pub fn as_slice(&self) -> Option<&[T]> {
self.0.as_slice()
... | code_fim | hard | {
"lang": "rust",
"repo": "japaric-archived/linalg.rs",
"path": "/src/linear.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.mir.local_decls
}
}
pub fn mir_binop_to_refine_op(op: mir::BinOp) -> BinOpKind {
match op {
mir::BinOp::Add => BinOpKind::Add,
mir::BinOp::Sub => BinOpKind::Sub,
mir::BinOp::Mul => BinOpKind::Mul,
mir::BinOp::Div => BinOpKind::Div,
mir::BinOp:... | code_fim | hard | {
"lang": "rust",
"repo": "nilehmann/liquid-rust",
"path": "/old/refinements/typeck.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let b = solver.check_sat()?;
println!(" {{{:?}}} <: {{{:?}}} {}", lhs, rhs, !b);
Ok(())
}
}
impl<'tcx> mir::HasLocalDecls<'tcx> for ReftChecker<'_, '_, 'tcx> {
fn local_decls(&self) -> &IndexVec<mir::Local, mir::LocalDecl<'tcx>> {
&self.mir.local_decls
}
... | code_fim | hard | {
"lang": "rust",
"repo": "nilehmann/liquid-rust",
"path": "/old/refinements/typeck.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nilehmann/liquid-rust path: /old/refinements/typeck.rs
{SmtRes, Solver};
use crate::syntax::ast::{BinOpKind, UnOpKind};
use rustc_data_structures::graph::WithStartNode;
use rustc_hir::BodyId;
use rustc_index::vec::IndexVec;
use rustc_index::{bit_set::BitSet, vec::Idx};
use rustc_middle::mir::{se... | code_fim | hard | {
"lang": "rust",
"repo": "nilehmann/liquid-rust",
"path": "/old/refinements/typeck.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Keep only the unique values in every sub-array.
pub fn unique_stable(self) -> Expr {
self.0
.map_private(FunctionExpr::ArrayExpr(ArrayFunction::Unique(true)))
}
}<|fim_prefix|>// repo: pola-rs/polars path: /crates/polars-plan/src/dsl/array.rs
use crate::dsl::function_e... | code_fim | medium | {
"lang": "rust",
"repo": "pola-rs/polars",
"path": "/crates/polars-plan/src/dsl/array.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pola-rs/polars path: /crates/polars-plan/src/dsl/array.rs
use crate::dsl::function_expr::{ArrayFunction, FunctionExpr};
use crate::prelude::*;
/// Specialized expressions for [`Series`][Series] of [`DataType::List`][DataType::List].
///
/// [Series]: polars_core::prelude::Series
/// [DataType::... | code_fim | medium | {
"lang": "rust",
"repo": "pola-rs/polars",
"path": "/crates/polars-plan/src/dsl/array.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ergoplatform/sigma-rust path: /ergo-lib/src/wallet/ext_pub_key.rs
//! Extended public key operations according to BIP-32
use std::convert::TryInto;
use ergo_chain_types::EcPoint;
use ergotree_interpreter::sigma_protocol::private_input::DlogProverInput;
use ergotree_ir::chain::address::Address;
... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/ergo-lib/src/wallet/ext_pub_key.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> use super::*;
#[test]
fn bip32_test_vector0() {
// from https://en.bitcoin.it/wiki/BIP_0032_TestVectors
// Chain m/0' from Test vector 1
// The difference between path "m/0'" and our "m/44'/429'/0" does not matter
// since we only testing soft derivation for ch... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/ergo-lib/src/wallet/ext_pub_key.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn ergo_node_key_tree_derivation_from_seed() {
// Tests against the following ergo node test vector:
// https://github.com/ergoplatform/ergo/blob/c320810c498bca25a44197840c7c5a86440c5906/ergo-wallet/src/test/scala/org/ergoplatform/wallet/secrets/ExtendedPublicKeySpec.scala#... | code_fim | hard | {
"lang": "rust",
"repo": "ergoplatform/sigma-rust",
"path": "/ergo-lib/src/wallet/ext_pub_key.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nakrez/store.rs path: /src/main.rs
//! This is the core server of store.rs
#![cfg_attr(feature="clippy", feature(plugin))]
#![cfg_attr(feature="clippy", plugin(clippy))]
#![feature(custom_derive, plugin)]
#![plugin(serde_macros)]
extern crate docopt;
use docopt::Docopt;
<|fim_suffix|> i... | code_fim | hard | {
"lang": "rust",
"repo": "Nakrez/store.rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>const USAGE: &'static str = "
In-memory tree based key value database
Usage:
store-bin <ip> <port>
store-bin (-h | --help)
store-bin --version
Options:
-h --help Show this screen.
--version Show version.
";
fn main() {
let args = Docopt::new(USAGE)
.and_then(... | code_fim | medium | {
"lang": "rust",
"repo": "Nakrez/store.rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: devdufutur/chuck-norust path: /src/winreg.rs
use winreg::enums::{HKEY_CURRENT_USER};
use winreg::RegKey;
use winreg::types::{FromRegValue, ToRegValue};
use std::ffi::OsStr;
fn read_value<T: FromRegValue, N: AsRef<OsStr>>(key_name: N, default: T) -> T {
let hkcu = RegKey::predef(HKEY_C... | code_fim | medium | {
"lang": "rust",
"repo": "devdufutur/chuck-norust",
"path": "/src/winreg.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn write_silent_notification(silent: bool) {
write_value("SilentNotification", if silent { 1u32 } else { 0u32 });
}<|fim_prefix|>// repo: devdufutur/chuck-norust path: /src/winreg.rs
use winreg::enums::{HKEY_CURRENT_USER};
use winreg::RegKey;
use winreg::types::{FromRegValue, ToRegValue};
us... | code_fim | hard | {
"lang": "rust",
"repo": "devdufutur/chuck-norust",
"path": "/src/winreg.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn write_notification_interval(interval: u32) {
write_value("NotificationInterval", interval);
}
pub fn write_silent_notification(silent: bool) {
write_value("SilentNotification", if silent { 1u32 } else { 0u32 });
}<|fim_prefix|>// repo: devdufutur/chuck-norust path: /src/winreg.rs
us... | code_fim | hard | {
"lang": "rust",
"repo": "devdufutur/chuck-norust",
"path": "/src/winreg.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Config {
client: ClientConfig::default(),
logging: LoggingConfig::default(),
mouse: MouseConfig::default(),
}
}
}<|fim_prefix|>// repo: BlenderCN-Org/eternalreckoning path: /client/src/util/config.rs
use serde::Deserialize;
use crate::client::Clien... | code_fim | medium | {
"lang": "rust",
"repo": "BlenderCN-Org/eternalreckoning",
"path": "/client/src/util/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BlenderCN-Org/eternalreckoning path: /client/src/util/config.rs
use serde::Deserialize;
use crate::client::ClientConfig;
use crate::input::MouseConfig;
use super::logging::LoggingConfig;
#[derive(Deserialize)]
#[serde(default, rename_all = "kebab-case")]
pub struct Config {
pub client: Cli... | code_fim | medium | {
"lang": "rust",
"repo": "BlenderCN-Org/eternalreckoning",
"path": "/client/src/util/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kalihui/codehub path: /rust/httppost/reqwest/src/main.rs
extern crate reqwest;
use std::collections::HashMap;
use std::process::Command;
fn main(){
let theusername = Command::new("whoami")
.output()
.expect("sh command failed to start")
.stdout;
let username = S... | code_fim | medium | {
"lang": "rust",
"repo": "kalihui/codehub",
"path": "/rust/httppost/reqwest/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let computer_ip = String::from_utf8_lossy(&thecomputer_ip).to_string();
let cmd="hi".to_string();
let mut map = HashMap::new();
map.insert("computer_ip", computer_ip);
map.insert("username", username);
map.insert("cmd",cmd);
let client = reqwest::Client::new();
let res = cl... | code_fim | hard | {
"lang": "rust",
"repo": "kalihui/codehub",
"path": "/rust/httppost/reqwest/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: saturn-xiv/yarrow path: /src/liang_yi.rs
use std::convert::From;
use std::fmt::{self, Write};
lazy_static! {
pub static ref LIANG_YI: Vec<LiangYi> = vec![LiangYi::Yang, LiangYi::Yin];
}
#[derive(Serialize, Deserialize, PartialEq, Clone)]
#[serde(rename_all = "camelCase")]
pub enum LiangYi ... | code_fim | hard | {
"lang": "rust",
"repo": "saturn-xiv/yarrow",
"path": "/src/liang_yi.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl fmt::Debug for LiangYi {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Yang => f.write_char('陽'),
Self::Yin => f.write_char('陰'),
}
}
}<|fim_prefix|>// repo: saturn-xiv/yarrow path: /src/liang_yi.rs
use std::convert::Fro... | code_fim | hard | {
"lang": "rust",
"repo": "saturn-xiv/yarrow",
"path": "/src/liang_yi.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>sult.push(Box::new(key_is_down::KeyIsDownOp {}));
result.push(Box::new(mouse_get_position::MouseGetPositionOp {}));
result.push(Box::new(omit_key_once::OmitKeyOnceOp {}));
result
}<|fim_prefix|>// repo: AustinHaugerud/oxidsys path: /src/language/operations/input/mod.rs
use language::operation... | code_fim | hard | {
"lang": "rust",
"repo": "AustinHaugerud/oxidsys",
"path": "/src/language/operations/input/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> result.push(Box::new(game_key_clicked::GameKeyClickedOp {}));
result.push(Box::new(game_key_is_down::GameKeyIsDownOp {}));
result.push(Box::new(key_clicked::KeyClickedOp {}));
result.push(Box::new(key_is_down::KeyIsDownOp {}));
result.push(Box::new(mouse_get_position::MouseGetPositionOp {... | code_fim | medium | {
"lang": "rust",
"repo": "AustinHaugerud/oxidsys",
"path": "/src/language/operations/input/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AustinHaugerud/oxidsys path: /src/language/operations/input/mod.rs
use language::operations::Operation;
pub mod clear_omitted_keys;
pub mod game_key_clicked;
pub mod game_key_is_down;
pub mod key_clicked;
pub mod key_is_down;
pub mod mouse_get_position;
pub mod omit_key_once;
pub fn load_operan... | code_fim | medium | {
"lang": "rust",
"repo": "AustinHaugerud/oxidsys",
"path": "/src/language/operations/input/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ptr = 0;
let mut i = 0;
let lines = source.lines();
for line in lines {
let lnlen = line.chars().count();
ptr += lnlen + 1;
if ptr > pos {
break;
}
i += 1;
}
i
}
fn get_error_info(kind: ErrorKind) -> (String, String) ... | code_fim | hard | {
"lang": "rust",
"repo": "projectfluent/fluent-rs",
"path": "/fluent-cli/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: projectfluent/fluent-rs path: /fluent-cli/src/lib.rs
use std::cmp;
use std::fs::File;
use std::io;
use std::io::Read;
use annotate_snippets::display_list::DisplayList;
use annotate_snippets::formatter::DisplayListFormatter;
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Sni... | code_fim | hard | {
"lang": "rust",
"repo": "projectfluent/fluent-rs",
"path": "/fluent-cli/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = parse(source.as_str());
match res {
Ok(res) => print_entries_resource(&res),
Err((res, errors)) => {
print_entries_resource(&res);
if silent {
return;
};
println!("==============================\n");
... | code_fim | hard | {
"lang": "rust",
"repo": "projectfluent/fluent-rs",
"path": "/fluent-cli/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_export]
macro_rules! dispatch_datum_by_size {
($($path:ident)::* ($dt:expr) ($($args:expr),*)) => { {
use $crate::datum::DatumType;
match $dt {
DatumType::Bool => $($path)::*::<i8>($($args),*),
DatumType::U8 => $($path)::*::<i8>($($args),*),
... | code_fim | hard | {
"lang": "rust",
"repo": "TrendingTechnology/tract",
"path": "/core/src/ops/macros.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TrendingTechnology/tract path: /core/src/ops/macros.rs
#[macro_export]
macro_rules! as_op {
() => {
fn as_op(&self) -> &dyn Op {
self
}
fn as_op_mut(&mut self) -> &mut dyn Op {
self
}
};
}
#[macro_export]
macro_rules! op_as_typed_... | code_fim | hard | {
"lang": "rust",
"repo": "TrendingTechnology/tract",
"path": "/core/src/ops/macros.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zackmdavis/Exercises_A path: /Stockfighter/Trades_Exec/src/trade.rs
use std::collections::BTreeMap;
use std::io;
use std::io::{Read, Write};
use hyper::client::Client;
use hyper::header::Headers;
use hyper::method::Method;
use serde_json;
use time;
use book::{Fill, Quote, Cents, Shares, Bid, A... | code_fim | hard | {
"lang": "rust",
"repo": "zackmdavis/Exercises_A",
"path": "/Stockfighter/Trades_Exec/src/trade.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_stocks(&self) -> String {
self.get(format!("{}/venues/{}/stocks", BASE_URL, self.venue))
}
pub fn get_order_book(&self) -> Option<OrderBook> {
let response_buffer = self.get(
format!("{}/venues/{}/stocks/{}", BASE_URL,
self.venue, sel... | code_fim | hard | {
"lang": "rust",
"repo": "zackmdavis/Exercises_A",
"path": "/Stockfighter/Trades_Exec/src/trade.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn order(&self, quantity: Shares, price: Cents,
action: Action, order_type: OrderType) -> OrderId {
let client = Client::new();
let direction_parameter = match action {
Action::Buy => "buy",
Action::Sell => "sell"
};
let orde... | code_fim | hard | {
"lang": "rust",
"repo": "zackmdavis/Exercises_A",
"path": "/Stockfighter/Trades_Exec/src/trade.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(snippet)
}
#[allow(dead_code)]
pub fn find_all(
conn: &DbConn,
visible_only: bool,
page: i64,
page_size: i64,
) -> Result<Vec<Self>, ModelError> {
use crate::schema::snippets::dsl::{hidden, shared_on, snippets};
use diesel::prelud... | code_fim | hard | {
"lang": "rust",
"repo": "idevgames/idevgames.com",
"path": "/cargo-project/src/models/snippets.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: idevgames/idevgames.com path: /cargo-project/src/models/snippets.rs
use super::{last_insert_rowid, ModelError};
use crate::db::DbConn;
use chrono::{NaiveDateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Queryable, Serialize)]
#[serde(rename_all = "camelCase")]
pu... | code_fim | hard | {
"lang": "rust",
"repo": "idevgames/idevgames.com",
"path": "/cargo-project/src/models/snippets.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let q = snippets
.order(shared_on.desc())
.limit(page_size)
.offset(page * page_size);
let r = if visible_only {
q.filter(hidden.eq(false)).load::<Snippet>(conn)?
} else {
q.load::<Snippet>(conn)?
};
Ok(r... | code_fim | hard | {
"lang": "rust",
"repo": "idevgames/idevgames.com",
"path": "/cargo-project/src/models/snippets.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wayhome/haproxy-consul-rs path: /src/main.rs
extern crate getopts;
extern crate serialize;
extern crate consul;
extern crate rustache;
use getopts::{optopt,reqopt,optflag,getopts,short_usage, usage};
use std::os;
use std::collections::HashMap;
use std::io::timer;
use std::time::Duration;
use s... | code_fim | hard | {
"lang": "rust",
"repo": "wayhome/haproxy-consul-rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let program = args[0].clone();
let help_text: &'static str = "
Watch services change in Consul and dynamically configures
HAProxy backends. The process runs continuously, monitoring
all the backends for changes. When there is a change, the template
file is rendered to a destinati... | code_fim | hard | {
"lang": "rust",
"repo": "wayhome/haproxy-consul-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustKernal/tinix-alloc path: /src/lib.rs
#![no_std]
#![feature(alloc_error_handler)] // at the top of the file
extern crate alloc;
use bootloader::BootInfo;
pub mod paging;
pub mod memory;
pub mod allocator;
pub mod structures;
use alloc::alloc::{GlobalAlloc, Layout};
use core::ptr::null_mut;
... | code_fim | hard | {
"lang": "rust",
"repo": "RustKernal/tinix-alloc",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct DummyAllocator;
unsafe impl GlobalAlloc for DummyAllocator {
unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
null_mut()
}
unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {
panic!("dealloc should be never called")
}
}<|fim_prefix|>// repo: RustKern... | code_fim | hard | {
"lang": "rust",
"repo": "RustKernal/tinix-alloc",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PaulL48/comp442-compiler path: /semantic_analyzer/src/symbol_table/param.rs
use crate::ast_validation::FunctionParameter;
use crate::format_table::FormatTable;
use crate::sizes;
use derive_getters::Getters;
use std::default::Default;
use std::fmt;
use crate::symbol_table::utils;
// This is the... | code_fim | hard | {
"lang": "rust",
"repo": "PaulL48/comp442-compiler",
"path": "/semantic_analyzer/src/symbol_table/param.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl FormatTable for Param {
fn lines(&self, _: usize) -> Vec<String> {
vec![format!(
"{:10}| {:10}| {:10}| {:<10}|",
"param",
self.id,
self.type_string(),
self.bytes
)]
}
}
impl PartialEq for Param {
fn eq(&self, oth... | code_fim | medium | {
"lang": "rust",
"repo": "PaulL48/comp442-compiler",
"path": "/semantic_analyzer/src/symbol_table/param.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl PartialEq<FunctionParameter<'_>> for Param {
fn eq(&self, other: &FunctionParameter) -> bool {
self.data_type == other.data_type()
}
}
impl Param {
pub fn from(function_parameter: &FunctionParameter) -> Self {
Param {
id: function_parameter.id().to_string(),
... | code_fim | hard | {
"lang": "rust",
"repo": "PaulL48/comp442-compiler",
"path": "/semantic_analyzer/src/symbol_table/param.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() -> Result<()> {
unsafe {
let mut statbuf: stat = mem::zeroed();
stat(c_str!("foo"), &mut statbuf).non_negative()?;
chmod(c_str!("foo"), (statbuf.st_mode & !S_IXGRP) | S_ISGID).non_negative()?;
chmod(c_str!("bar"), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH).non_neg... | code_fim | medium | {
"lang": "rust",
"repo": "shioyama18/apue",
"path": "/example/ch04_files_and_directories/f12_chmod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
let mut statbuf: stat = mem::zeroed();
stat(c_str!("foo"), &mut statbuf).non_negative()?;
chmod(c_str!("foo"), (statbuf.st_mode & !S_IXGRP) | S_ISGID).non_negative()?;
chmod(c_str!("bar"), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH).non_negative()?;
}
Ok(()... | code_fim | medium | {
"lang": "rust",
"repo": "shioyama18/apue",
"path": "/example/ch04_files_and_directories/f12_chmod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shioyama18/apue path: /example/ch04_files_and_directories/f12_chmod.rs
//! This program needs to be run as root in order to add S_ISGID to "foo"
<|fim_suffix|>fn main() -> Result<()> {
unsafe {
let mut statbuf: stat = mem::zeroed();
stat(c_str!("foo"), &mut statbuf).non_nega... | code_fim | medium | {
"lang": "rust",
"repo": "shioyama18/apue",
"path": "/example/ch04_files_and_directories/f12_chmod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// 指定したソケット ID と種別のイベントを待機
fn wait_event(&self, sock_id: SockID, kind: TCPEventKind) {
let (lock, cvar) = &self.event_condvar;
let mut event = lock.lock().unwrap();
loop {
if let Some(ref e) = *event {
if e.sock_id == sock_id && e.kind == kind {... | code_fim | hard | {
"lang": "rust",
"repo": "hayasshi/rust-tcp-book",
"path": "/toytcp/src/tcp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> dbg!("synsent handler");
if packet.get_flag() & tcpflags::ACK > 0
&& socket.send_param.unacked_seq <= packet.get_ack()
&& packet.get_ack() <= socket.send_param.next
&& packet.get_flag() & tcpflags::SYN > 0
{
socket.recv_param.next = p... | code_fim | hard | {
"lang": "rust",
"repo": "hayasshi/rust-tcp-book",
"path": "/toytcp/src/tcp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hayasshi/rust-tcp-book path: /toytcp/src/tcp.rs
use crate::packet::TCPPacket;
use crate::socket::{SockID, Socket, TcpStatus};
use crate::tcpflags;
use anyhow::{Context, Result};
use pnet::packet::{ip::IpNextHeaderProtocols, tcp::TcpPacket, Packet};
use pnet::transport::{self, TransportChannelTyp... | code_fim | hard | {
"lang": "rust",
"repo": "hayasshi/rust-tcp-book",
"path": "/toytcp/src/tcp.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.borrow().seat()
}
}
impl<S: Session> Session for Arc<Mutex<S>> {
type Error = S::Error;
fn open(&mut self, path: &Path, flags: OFlag) -> Result<RawFd, Self::Error> {
self.lock().unwrap().open(path, flags)
}
fn close(&mut self, fd: RawFd) -> Result<(), Self::Erro... | code_fim | hard | {
"lang": "rust",
"repo": "cheako/smithay",
"path": "/src/backend/session/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cheako/smithay path: /src/backend/session/mod.rs
//!
//! Abstraction of different session APIs.
//!
//! Sessions provide a way for multiple graphical systems to run in parallel by providing
//! mechanisms to switch between and handle device access and permissions for every running
//! instance.
... | code_fim | hard | {
"lang": "rust",
"repo": "cheako/smithay",
"path": "/src/backend/session/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexlegg/yarg path: /src/cpu.rs
#![allow(clippy::identity_op)]
use crate::asm::operation::{Address, Condition, Reg};
use crate::cartridge::Cartridge;
use crate::joypad::Joypad;
use crate::ppu::Ppu;
use crate::timer::Timer;
use serde::{Deserialize, Serialize};
#[derive(Copy, Clone, Debug)]
pub e... | code_fim | hard | {
"lang": "rust",
"repo": "alexlegg/yarg",
"path": "/src/cpu.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn read_mem8(&self, addr: u16) -> Result<u8, String> {
if self.bootrom_enabled && addr <= 0xff {
if let Some(ref bootrom) = self.bootrom {
return Ok(bootrom[addr as usize]);
}
Err("Bootrom is enabled but there is no bootrom".to_string())
} else if addr <= 0x7fff {
... | code_fim | hard | {
"lang": "rust",
"repo": "alexlegg/yarg",
"path": "/src/cpu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ids = make_id_vec(t.len());
c.fields = Some("pri,done".to_owned());
tsort::sort(&mut ids, &t, &c);
assert_eq!(ids, vec![3, 2, 1, 0, 4, 5]);
let mut ids = make_id_vec(t.len());
c.fields = Some("proj,ctx".to_owned());
tsort::sort(&mut ids, &t, &c);
assert_eq!(ids, ve... | code_fim | hard | {
"lang": "rust",
"repo": "VladimirMarkelov/todo_lib",
"path": "/tests/sort.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ids = make_id_vec(t.len());
c.fields = Some("done".to_owned());
tsort::sort(&mut ids, &t, &c);
assert_eq!(ids, vec![1, 3, 5, 4, 2, 0]);
}
#[test]
fn few_fields() {
let t = init_tasks();
let mut c = tsort::Conf::default();
let mut ids = make_id_vec(t.len());
c.fiel... | code_fim | hard | {
"lang": "rust",
"repo": "VladimirMarkelov/todo_lib",
"path": "/tests/sort.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VladimirMarkelov/todo_lib path: /tests/sort.rs
use todo_lib::{todo, todotxt, tsort};
fn init_tasks() -> todo::TaskVec {
let mut t = Vec::new();
let now = chrono::Local::now().date_naive();
t.push(todotxt::Task::parse("call mother +family @parents", now));
t.push(todotxt::Task::... | code_fim | hard | {
"lang": "rust",
"repo": "VladimirMarkelov/todo_lib",
"path": "/tests/sort.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>xpected one of `(`, `)`, `,`, `::`, or `=`, found `d`
fn main() {}<|fim_prefix|>// repo: su225/rust path: /src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.rs
#![feature(custom_attribute)]
#[my_attr(a b c d)]
//~^ ERROR exp<|fim_middle|>ected one of `(`, `)`, `,`, `::`, or `=`, found... | code_fim | medium | {
"lang": "rust",
"repo": "su225/rust",
"path": "/src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: su225/rust path: /src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.rs
#![feature(custom_attribute)]
#[my_attr(a b c d)]
//~^ ERROR exp<|fim_suffix|>xpected one of `(`, `)`, `,`, `::`, or `=`, found `d`
fn main() {}<|fim_middle|>ected one of `(`, `)`, `,`, `::`, or `=`, found... | code_fim | medium | {
"lang": "rust",
"repo": "su225/rust",
"path": "/src/test/ui/feature-gates/feature-gate-unrestricted-attribute-tokens.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>+ 1) {
result.push((x, *y));
} else {
break;
}
}
result
}
pub fn tuples_to_flatten(tuples: &[(f64, f64)]) -> Vec<f64> {
let mut result = Vec::with_capacity(tuples.len() * 2);
for (x, y) in tuples {
result.push(*x);
result.push(*y);
}
result
}<|fim_prefix|>// repo: ... | code_fim | medium | {
"lang": "rust",
"repo": "minecrawler/cubic_spline",
"path": "/src/convert.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: minecrawler/cubic_spline path: /src/convert.rs
pub fn flatten_to_tuples(pts: &[f64]) -> Vec<(f64, f64)> {
let len = (pts.len() / 2) + 1;
let mut result = Vec::with_capacity(len);
for<|fim_suffix|>+ 1) {
result.push((x, *y));
} else {
break;
}
}
result
}
pub fn tupl... | code_fim | medium | {
"lang": "rust",
"repo": "minecrawler/cubic_spline",
"path": "/src/convert.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut old_key = None;
for i in 0..self.elements {
let elem = self.get_by_position(i);
if !(self.bounds[0] <= elem.key) {
println!("{:?}", self);
}
assert!(self.bounds[0] <= elem.key);
assert!(elem.key <= self.bou... | code_fim | hard | {
"lang": "rust",
"repo": "gdanezis/auth_db",
"path": "/src/auth_db.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gdanezis/auth_db path: /src/auth_db.rs
inner_scratch in computed.into_iter() {
let (ws, ret, spare) = inner_scratch.split();
scratch.returns.extend(ret);
scratch.spare_elements.extend(spare);
scratch.work_set.extend(ws);
}
this_nod... | code_fim | hard | {
"lang": "rust",
"repo": "gdanezis/auth_db",
"path": "/src/auth_db.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // The node is full but there are more
// elements in the stream.
if new_node.elements == capacity {
// we keep the right bound as the largest element.
break;
}
// Safe to unwrap due to previous check.
... | code_fim | hard | {
"lang": "rust",
"repo": "gdanezis/auth_db",
"path": "/src/auth_db.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dai-dao/learn_rust path: /r-sonic-client/src/channels/search.rs
use super::{Channel, ChannelMode, SonicStream};
use std::net::{ToSocketAddrs};
use crate::result::*;
use crate::commands::{QuitCommand};
<|fim_suffix|>
impl Channel for SearchChannel {
fn start<A: ToSocketAddrs, S: ToString>(a... | code_fim | medium | {
"lang": "rust",
"repo": "dai-dao/learn_rust",
"path": "/r-sonic-client/src/channels/search.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl SearchChannel {
init_command!( use QuitCommand for fn quit());
}
impl SearchChannel {
init_channel_call! ( 2);
}<|fim_prefix|>// repo: dai-dao/learn_rust path: /r-sonic-client/src/channels/search.rs
use super::{Channel, ChannelMode, SonicStream};
use std::net::{ToSocketAddrs};
use crate::... | code_fim | hard | {
"lang": "rust",
"repo": "dai-dao/learn_rust",
"path": "/r-sonic-client/src/channels/search.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.read_buf.reserve(1);
}
let buf = self.read_buf.chunk_mut();
let buf = unsafe {
for i in 0..buf.len() {
buf.write_byte(i, 0);
}
std::slice::from_raw_parts_mut(buf.as_mut_ptr(), buf... | code_fim | hard | {
"lang": "rust",
"repo": "1tgr/rust-websocket-lite",
"path": "/websocket-lite/src/sync.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 1tgr/rust-websocket-lite path: /websocket-lite/src/sync.rs
use std::io::{Read, Write};
use bytes::{BufMut, BytesMut};
use tokio_util::codec::{Decoder, Encoder};
pub struct Framed<S, C> {
stream: S,
codec: C,
read_buf: BytesMut,
write_buf: BytesMut,
}
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "1tgr/rust-websocket-lite",
"path": "/websocket-lite/src/sync.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mcoblenz/shifgrethor path: /src/lib/gc/state.rs
use std::cell::{Ref, RefCell};
use std::pin::Pin;
use std::ptr::NonNull;
use log::*;
use crate::alloc::{Allocation, Data};
use crate::gc_ptr::GcPtr;
use crate::list::List;
use crate::trace::Trace;
#[derive(Default)]
pub struct GcState {
obje... | code_fim | hard | {
"lang": "rust",
"repo": "mcoblenz/shifgrethor",
"path": "/src/lib/gc/state.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn set_root<T: Trace + ?Sized>(self: Pin<&Self>, idx: usize, ptr: GcPtr<T>) {
let root: NonNull<Allocation<Data>> = ptr.erased();
debug!("ENROOTING root at: {:x} (idx {:x})", root.as_ptr() as usize, idx);
self.roots.borrow_mut()[idx] = Some(root);
}
pub fn... | code_fim | hard | {
"lang": "rust",
"repo": "mcoblenz/shifgrethor",
"path": "/src/lib/gc/state.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn roots(&self) -> Ref<'_, [Option<NonNull<Allocation<Data>>>]> {
Ref::map(self.roots.borrow(), |v| &v[..])
}
pub fn objects<'a>(self: Pin<&'a Self>) -> Pin<&'a List<Allocation<Data>>> {
unsafe { Pin::map_unchecked(self, |this| &this.objects) }
}
}<|fim_prefix|>// repo... | code_fim | hard | {
"lang": "rust",
"repo": "mcoblenz/shifgrethor",
"path": "/src/lib/gc/state.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>zzing::fuzz_default_config(Strategy::Auto).unwrap(),
Some(Duration::from_secs(20)),
);
});<|fim_prefix|>// repo: goodbyekansas/wasmtime path: /fuzz/fuzz_targets/instantiate-maybe-invalid.rs
#![no_main]
use libfuzzer_sys::fuzz_target;
use std::time::Duration;
use wasm_smith::MaybeInvalidModu<... | code_fim | hard | {
"lang": "rust",
"repo": "goodbyekansas/wasmtime",
"path": "/fuzz/fuzz_targets/instantiate-maybe-invalid.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: goodbyekansas/wasmtime path: /fuzz/fuzz_targets/instantiate-maybe-invalid.rs
#![no_main]
use libfuzzer_sys::fuzz_target;
use std::time::Duration;
use wasm_smith::MaybeInvalidModu<|fim_suffix|>{
oracles::instantiate_with_config(
&module.to_bytes(),
false,
wasmtime_fuz... | code_fim | medium | {
"lang": "rust",
"repo": "goodbyekansas/wasmtime",
"path": "/fuzz/fuzz_targets/instantiate-maybe-invalid.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pstetz/misc path: /leetcode/921.rs
impl Solution {
pub fn min_add_to_make_valid(s: String) -> i32 {
let mut surplus: i32 = 0;
let mut needed: i32 = 0;
for c in s.chars() {
if c == '(' {
surplus += 1;
<|fim_suffix|> {
sur... | code_fim | hard | {
"lang": "rust",
"repo": "pstetz/misc",
"path": "/leetcode/921.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
surplus -= 1;
}
}
}
surplus + needed
}
}<|fim_prefix|>// repo: pstetz/misc path: /leetcode/921.rs
impl Solution {
pub fn min_add_to_make_valid(s: String) -> i32 {
let mut surplus: i32 = 0;
let mut needed: i32 = 0;
... | code_fim | hard | {
"lang": "rust",
"repo": "pstetz/misc",
"path": "/leetcode/921.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: corollaries/azure-iothub-service-rs path: /src/query.rs
use bytes::buf::BufExt as _;
use hyper::{Body, Client, Method, Request};
use hyper_tls::HttpsConnector;
use serde_json::json;
use crate::error::{BuilderError, BuilderErrorType};
use crate::{IoTHubService, API_VERSION};
pub struct Query<'a... | code_fim | hard | {
"lang": "rust",
"repo": "corollaries/azure-iothub-service-rs",
"path": "/src/query.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(Query {
iothub_service: self.iothub_service,
query,
})
}
}
#[cfg(test)]
mod tests {
use crate::IoTHubService;
#[test]
fn querybuilder_success() -> Result<(), Box<dyn std::error::Error>> {
use crate::query::QueryBuilder;
let iothu... | code_fim | hard | {
"lang": "rust",
"repo": "corollaries/azure-iothub-service-rs",
"path": "/src/query.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A simple struct that represents a point or position.
#[derive(Copy, Clone, Debug, PartialEq, Default)]
pub struct Point {
/// The x-coordinate of the point.
pub x: f64,
/// The y-coordinate of the point.
pub y: f64
}<|fim_prefix|>// repo: matanui159/mint2d.rs path: /src/lib.rs
// Copyright 2018 ... | code_fim | hard | {
"lang": "rust",
"repo": "matanui159/mint2d.rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matanui159/mint2d.rs path: /src/lib.rs
// Copyright 2018 Joshua Minter
//
// 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/LIC... | code_fim | hard | {
"lang": "rust",
"repo": "matanui159/mint2d.rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: phucloc8697/advent-of-code-2018-rust path: /day12/src/main.rs
use lazy_static::lazy_static;
use regex::Regex;
use std::collections::HashMap;
use std::error::Error;
use std::fmt;
use std::fs;
use std::str::FromStr;
macro_rules! err {
($($tt:tt)*) => { Err(Box::<dyn Error>::from(format!($($tt... | code_fim | hard | {
"lang": "rust",
"repo": "phucloc8697/advent-of-code-2018-rust",
"path": "/day12/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.