text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: roSievers/sogo path: /src/tests/mod.rs
#[cfg(test)]
use game;
use ai;
use ai::run_match;
use constants::LINES;
use std::sync::Arc;
#[test]
fn match_mc() {
let structure = Arc::new(game::Structure::new(&LINES));
let mut white_player = ai::mc::MonteCarloAI::new(1000);
let mut black_pl... | code_fim | hard | {
"lang": "rust",
"repo": "roSievers/sogo",
"path": "/src/tests/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 0..10000 {
// Ensure that all positions returned by the Subset iterator are
// contained in the Subset.
let subset = game::Subset(rng.next_u64());
for position in subset.iter() {
println!("{:?}", position);
assert!(subset.contains(positi... | code_fim | medium | {
"lang": "rust",
"repo": "roSievers/sogo",
"path": "/src/tests/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: risooonho/bevy_prototype_lyon path: /src/utils.rs
//! Utility types and conversion traits.
use bevy::math::Vec2;
use lyon_tessellation::{
math::{Point, Vector},
FillOptions, StrokeOptions,
};
/// Determines if a shape must be filled or stroked.
#[derive(Debug, Clone, Copy, PartialEq)]
... | code_fim | medium | {
"lang": "rust",
"repo": "risooonho/bevy_prototype_lyon",
"path": "/src/utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Point::new(self.x, self.y)
}
}
impl Convert<Vec2> for Point {
fn convert(self) -> Vec2 {
Vec2::new(self.x, self.y)
}
}
impl Convert<Vector> for Vec2 {
fn convert(self) -> Vector {
Vector::new(self.x, self.y)
}
}<|fim_prefix|>// repo: risooonho/bevy_prototype_l... | code_fim | medium | {
"lang": "rust",
"repo": "risooonho/bevy_prototype_lyon",
"path": "/src/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Vec2::new(self.x, self.y)
}
}
impl Convert<Vector> for Vec2 {
fn convert(self) -> Vector {
Vector::new(self.x, self.y)
}
}<|fim_prefix|>// repo: risooonho/bevy_prototype_lyon path: /src/utils.rs
//! Utility types and conversion traits.
use bevy::math::Vec2;
use lyon_tessella... | code_fim | hard | {
"lang": "rust",
"repo": "risooonho/bevy_prototype_lyon",
"path": "/src/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wehjin/yui path: /src/yui/layout.rs
use std::fmt::Debug;
use std::ops::Deref;
use std::rc::Rc;
use crate::core::bounds::Bounds;
use crate::yui::{Focus, FocusMotion, FocusMotionFuture, FocusType};
#[derive(Debug, Clone)]
pub struct ActiveFocus {
pub focus: Option<Rc<Focus>>,
pub peers: Vec<Rc... | code_fim | hard | {
"lang": "rust",
"repo": "wehjin/yui",
"path": "/src/yui/layout.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn move_left(&self) -> ActiveFocus {
if self.send_motion(FocusMotion::Left) == FocusMotionFuture::Default {
self.next_focus(
|bounds, origin| bounds.is_left_of(origin),
|bounds, origin| bounds.left_rank(origin),
)
} else {
self.to_owned()
}
}
pub fn move_right(&self) -> Acti... | code_fim | hard | {
"lang": "rust",
"repo": "wehjin/yui",
"path": "/src/yui/layout.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn move_down(&self) -> ActiveFocus {
if self.send_motion(FocusMotion::Down) == FocusMotionFuture::Default {
self.next_focus(
|bounds, origin| bounds.is_below(origin),
|bounds, origin| bounds.down_rank(origin),
)
} else {
self.to_owned()
}
}
pub fn move_left(&self) -> ActiveF... | code_fim | hard | {
"lang": "rust",
"repo": "wehjin/yui",
"path": "/src/yui/layout.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
ByteValue::Expr(expr) => write!(f, "{}", expr),
ByteValue::String(_, vec) => {
write!(f, "\"{}\"", escape_string(vec))
}
}
}
}
impl fmt::Display for Directive {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
... | code_fim | hard | {
"lang": "rust",
"repo": "wtetzner/waterbear",
"path": "/src/ast.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> use crate::expression::Expr::*;
match expr {
Number(_, num, _) => Ok(*num),
_ => Err(EvaluationError::MustBeLiteralNumber(expr.span()))
}
}
pub fn eval_cnop(pos: i32, add: &Expr, multiple: &Expr) -> Result<i32,EvaluationError> {
let add = Di... | code_fim | hard | {
"lang": "rust",
"repo": "wtetzner/waterbear",
"path": "/src/ast.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wtetzner/waterbear path: /src/ast.rs
ate::instruction::Instr;
use crate::expression::{Expr, EvaluationError, Arg, IndirectionMode};
use std::fmt;
use crate::location::{Span, Positioned};
use std::collections::HashMap;
#[derive(Debug,Clone,Hash,PartialEq,Eq)]
pub struct MacroIdentifier {
nam... | code_fim | hard | {
"lang": "rust",
"repo": "wtetzner/waterbear",
"path": "/src/ast.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let len = data.len();
if addr as usize + len > AVAILABLE_STORAGE {
return Err(Error::TooMuchData);
}
let mut addr: u16 = addr;
let mut writebuf: [u8; PAGESIZE + 2] = [0; PAGESIZE + 2];
let mut wrptr: usize = 0;
while wrptr < data.len() {... | code_fim | hard | {
"lang": "rust",
"repo": "Maldus512/mcp-eeprom-rs",
"path": "/src/mcp24lc512.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Maldus512/mcp-eeprom-rs path: /src/mcp24lc512.rs
use embedded_hal::blocking::i2c::{Write, WriteRead};
use embedded_hal::digital::v2::OutputPin;
use embedded_time::duration::Milliseconds;
use embedded_time::Clock;
const AVAILABLE_STORAGE: usize = 64_000;
const PAGESIZE: usize = 128;
const DEFAUL... | code_fim | hard | {
"lang": "rust",
"repo": "Maldus512/mcp-eeprom-rs",
"path": "/src/mcp24lc512.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn read_data(
&mut self,
addr: u16,
data: &mut [u8],
) -> Result<(), Error<I2C>> {
if addr as usize > AVAILABLE_STORAGE {
return Err(Error::OutOfRange);
}
if addr as usize + data.len() > AVAILABLE_STORAGE {
return Err(Err... | code_fim | hard | {
"lang": "rust",
"repo": "Maldus512/mcp-eeprom-rs",
"path": "/src/mcp24lc512.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fossabot/necsim-rust path: /necsim/impls/std/src/cogs/rng/pcg.rs
use std::fmt;
use pcg_rand::{seeds::PcgSeeder, Pcg64};
use rand::{RngCore as _, SeedableRng};
use necsim_core::cogs::{Backup, RngCore, SplittableRng};
#[allow(clippy::module_name_repetitions)]
pub struct Pcg(Pcg64);
impl Clone ... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/necsim-rust",
"path": "/necsim/impls/std/src/cogs/rng/pcg.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> (left, right)
}
fn split_to_stream(self, stream: u64) -> Self {
let mut state = self.0.get_state();
state.increment = (u128::from(stream) << 1) | 1;
Self(Pcg64::restore_state_with_no_verification(state))
}
}<|fim_prefix|>// repo: fossabot/necsim-rust path: /n... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/necsim-rust",
"path": "/necsim/impls/std/src/cogs/rng/pcg.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn split_to_stream(self, stream: u64) -> Self {
let mut state = self.0.get_state();
state.increment = (u128::from(stream) << 1) | 1;
Self(Pcg64::restore_state_with_no_verification(state))
}
}<|fim_prefix|>// repo: fossabot/necsim-rust path: /necsim/impls/std/src/cogs/rng/... | code_fim | hard | {
"lang": "rust",
"repo": "fossabot/necsim-rust",
"path": "/necsim/impls/std/src/cogs/rng/pcg.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ami-Solution/b0x path: /src/color.rs
use super::colored::*;
<|fim_suffix|> println!("{} {}({})", "found".white().bold(), ty, data);
}<|fim_middle|>/// Print which type is recognized
pub fn found(data: &str, ty: &str) {
let data = data.red().bold();
let ty = ty.yellow().bold();
| code_fim | medium | {
"lang": "rust",
"repo": "Ami-Solution/b0x",
"path": "/src/color.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{} {}({})", "found".white().bold(), ty, data);
}<|fim_prefix|>// repo: Ami-Solution/b0x path: /src/color.rs
use super::colored::*;
<|fim_middle|>/// Print which type is recognized
pub fn found(data: &str, ty: &str) {
let data = data.red().bold();
let ty = ty.yellow().bold();
| code_fim | medium | {
"lang": "rust",
"repo": "Ami-Solution/b0x",
"path": "/src/color.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Default)]
pub struct Table(pub(crate) HashMap<Value, Value>);
impl Table {
pub fn new() -> Self {
Self(HashMap::new())
}
pub fn get(&self, value: &Value) -> &Value {
if let Some(value) = self.0.get(value) {
value
} else {
&... | code_fim | hard | {
"lang": "rust",
"repo": "CurryPseudo/rua",
"path": "/src/vm/table.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CurryPseudo/rua path: /src/vm/table.rs
use std::collections::HashMap;
use crate::ConstantValue::*;
use crate::Value;
use crate::Value::*;
<|fim_suffix|>#[derive(Debug, Clone, Default)]
pub struct Table(pub(crate) HashMap<Value, Value>);
impl Table {
pub fn new() -> Self {
Self(Hash... | code_fim | hard | {
"lang": "rust",
"repo": "CurryPseudo/rua",
"path": "/src/vm/table.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: livexia/algorithm path: /blind_75_leetcode/src/main.rs
use std::error::Error;
use std::fs;
use std::io::Write;
use std::path::Path;
macro_rules! err {
($($tt:tt)*) => { Err(Box::<dyn Error>::from(format!($($tt)*))) }
}
type Result<T> = ::std::result::Result<T, Box<dyn Error>>;
use clap::Pa... | code_fim | hard | {
"lang": "rust",
"repo": "livexia/algorithm",
"path": "/blind_75_leetcode/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn parse_name(name: &str) -> ::std::result::Result<String, String> {
// if input is a url, than need to extract the name
// remove china url
let name = name.replace("https://leetcode.cn/problems/", "");
// remove international url
let name = name.replace("https://leetcode.com/problems/... | code_fim | hard | {
"lang": "rust",
"repo": "livexia/algorithm",
"path": "/blind_75_leetcode/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thelmn/geistchess path: /movegen/src/pieces.rs
orward { Direction::NE } else { Direction::SW };
let cp_r_dest = utils::slide(*piece_mask, 1, &dir);
if cp_l_dest & king_mask > 0 {
check_mask |= utils::slide(*king_mask, 1, &dir.opp())
... | code_fim | hard | {
"lang": "rust",
"repo": "thelmn/geistchess",
"path": "/movegen/src/pieces.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thelmn/geistchess path: /movegen/src/pieces.rs
pl From<bool> for SqOccupation {
fn from(player: bool) -> Self {
match player {
false => SqOccupation::Black,
true => SqOccupation::White,
}
}
}
pub mod std_pieces {
use crate::board::BitBoard;
... | code_fim | hard | {
"lang": "rust",
"repo": "thelmn/geistchess",
"path": "/movegen/src/pieces.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>const PIECETYPE_BITS: u8 = 3;
const PIECETYPE_MASK: u8 = 0b0111;
// Piece(0b0000_1xxx) for white pieces. Piece(0b0000_0xxx) for black pieces
#[derive(Copy, Clone, PartialEq)]
pub struct Piece {
pub piece_type: PieceType,
pub player: bool
}
impl Piece {
pub fn from_bits(piecebits: u8) ->... | code_fim | hard | {
"lang": "rust",
"repo": "thelmn/geistchess",
"path": "/movegen/src/pieces.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> from_val.0
}
}
impl Vector3f {
pub fn new(x:DefaultFloatType, y:DefaultFloatType, z:DefaultFloatType) -> Vector3f {
Vector3f(Vector3::<DefaultFloatType>::new(x,y,z))
}
pub fn transform(&self, mat: Matrix4<DefaultFloatType>) -> Vector3f {
Vector3f(Vector3::<Default... | code_fim | hard | {
"lang": "rust",
"repo": "moss-oliver/tremor",
"path": "/lib_math/src/vector.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: moss-oliver/tremor path: /lib_math/src/vector.rs
use std::ops::Add;
use std::ops::Sub;
use std::ops::Mul;
use std::ops::Div;
use std::ops::Index;
use std::ops::IndexMut;
use std::cmp::PartialEq;
use std::ops::Deref;
use base_num::BaseNum;
use matrix::Matrix4;
type DefaultFloatType = f32;
//tra... | code_fim | hard | {
"lang": "rust",
"repo": "moss-oliver/tremor",
"path": "/lib_math/src/vector.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fenjalien/apriltag-sys path: /bindings/bindings.rs
d::ptr::null::<pthread_mutex_t>())).__align as *const _ as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(pthread_mutex_t),
"::",
stringify!(__align)
)
);
}
#... | code_fim | hard | {
"lang": "rust",
"repo": "fenjalien/apriltag-sys",
"path": "/bindings/bindings.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
::std::mem::size_of::<image_f32>(),
24usize,
concat!("Size of: ", stringify!(image_f32))
);
assert_eq!(
::std::mem::align_of::<image_f32>(),
8usize,
concat!("Alignment of ", stringify!(image_f32))
);
assert_eq!(
unsafe... | code_fim | hard | {
"lang": "rust",
"repo": "fenjalien/apriltag-sys",
"path": "/bindings/bindings.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
::std::mem::size_of::<image_u8>(),
24usize,
concat!("Size of: ", stringify!(image_u8))
);
assert_eq!(
::std::mem::align_of::<image_u8>(),
8usize,
concat!("Alignment of ", stringify!(image_u8))
);
assert_eq!(
unsafe { &... | code_fim | hard | {
"lang": "rust",
"repo": "fenjalien/apriltag-sys",
"path": "/bindings/bindings.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tafia/quick-protobuf path: /quick-protobuf/tests/rust_protobuf/v2/issue_170.rs
#[test]
fn t() {
use super::{
issue_170_a::A, issue_170_b::B, issue_170_c::C, issue_170_common::Common, issue_170_d::D,
issue_170_e::E,
};
<|fim_suffix|> let c = C {
a: Some(a.clone... | code_fim | medium | {
"lang": "rust",
"repo": "tafia/quick-protobuf",
"path": "/quick-protobuf/tests/rust_protobuf/v2/issue_170.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let e = E {
a: Some(a.clone()),
b: Some(b.clone()),
c: Some(c.clone()),
d: Some(d.clone()),
common: Some(Common {}),
};
}<|fim_prefix|>// repo: tafia/quick-protobuf path: /quick-protobuf/tests/rust_protobuf/v2/issue_170.rs
#[test]
fn t() {
use super::{
... | code_fim | hard | {
"lang": "rust",
"repo": "tafia/quick-protobuf",
"path": "/quick-protobuf/tests/rust_protobuf/v2/issue_170.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
pub fn pext_u64(x: u64, mask: u64) -> u64 {
bitintr::x86::bmi2::pext(x, mask)
}<|fim_prefix|>// repo: blt/bitintr path: /asm/x86_bmi2_pext.rs
extern crate bitintr;
<|fim_middle|>#[no_mangle]
pub fn pext_u32(x: u32, mask: u32) -> u32 {
bitintr::x86::bmi2::pext(x, mask)
}
| code_fim | medium | {
"lang": "rust",
"repo": "blt/bitintr",
"path": "/asm/x86_bmi2_pext.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blt/bitintr path: /asm/x86_bmi2_pext.rs
extern crate bitintr;
<|fim_suffix|>#[no_mangle]
pub fn pext_u64(x: u64, mask: u64) -> u64 {
bitintr::x86::bmi2::pext(x, mask)
}<|fim_middle|>#[no_mangle]
pub fn pext_u32(x: u32, mask: u32) -> u32 {
bitintr::x86::bmi2::pext(x, mask)
}
| code_fim | medium | {
"lang": "rust",
"repo": "blt/bitintr",
"path": "/asm/x86_bmi2_pext.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rhorrace/exercism path: /rust/accumulate/src/lib.rs
/// What should the type of _function be?
pub fn map<T, S, F: FnMut(T) -> S>(input: Vec<T>,<|fim_suffix|>()
.map(function)
.collect()
}<|fim_middle|> function: F) -> Vec<S> {
input.into_iter | code_fim | easy | {
"lang": "rust",
"repo": "rhorrace/exercism",
"path": "/rust/accumulate/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> function: F) -> Vec<S> {
input.into_iter()
.map(function)
.collect()
}<|fim_prefix|>// repo: rhorrace/exercism path: /rust/accumulate/src/lib.rs
/// What should the type of _function be?
pub<|fim_middle|> fn map<T, S, F: FnMut(T) -> S>(input: Vec<T>, | code_fim | easy | {
"lang": "rust",
"repo": "rhorrace/exercism",
"path": "/rust/accumulate/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>()
.map(function)
.collect()
}<|fim_prefix|>// repo: rhorrace/exercism path: /rust/accumulate/src/lib.rs
/// What should the type of _function be?
pub<|fim_middle|> fn map<T, S, F: FnMut(T) -> S>(input: Vec<T>, function: F) -> Vec<S> {
input.into_iter | code_fim | medium | {
"lang": "rust",
"repo": "rhorrace/exercism",
"path": "/rust/accumulate/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Giovan/lumen path: /examples/spawn-chain/src/elixir/range.rs
use liblumen_alloc::erts::exception::Result;
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::{atom_unchecked, Term};
pub fn n<|fim_suffix|> (atom_unchecked("__struct__"), atom_unchecked("Elixi... | code_fim | medium | {
"lang": "rust",
"repo": "Giovan/lumen",
"path": "/examples/spawn-chain/src/elixir/range.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>hecked("last"), last),
])
.map_err(|alloc_err| alloc_err.into())
} else {
Err(liblumen_alloc::badarg!().into())
}
}<|fim_prefix|>// repo: Giovan/lumen path: /examples/spawn-chain/src/elixir/range.rs
use liblumen_alloc::erts::exception::Result;
use liblumen_alloc::e... | code_fim | hard | {
"lang": "rust",
"repo": "Giovan/lumen",
"path": "/examples/spawn-chain/src/elixir/range.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chrisduerr/wayland-rs path: /wayland-protocols/src/protocol_macro.rs
macro_rules! wayland_protocol(
($path:expr, [$($imports:path),*]) => {
#[cfg(feature = "client")]
pub use self::generated::client;
#[cfg(feature = "server")]
pub use self::generated::server;... | code_fim | hard | {
"lang": "rust",
"repo": "chrisduerr/wayland-rs",
"path": "/wayland-protocols/src/protocol_macro.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub mod __interfaces {
use wayland_server::protocol::__interfaces::*;
$(use $imports::{server::__interfaces::*};)*
wayland_scanner::generate_interfaces!($path);
}
use self::__interfaces::*;
... | code_fim | hard | {
"lang": "rust",
"repo": "chrisduerr/wayland-rs",
"path": "/wayland-protocols/src/protocol_macro.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kotovalexarian/rustraceroute path: /src/sockaddr_inx.rs
use std::{convert::TryInto, fmt, net::{IpAddr, Ipv4Addr, Ipv6Addr}};
#[derive(Clone, Copy)]
pub enum SockaddrInx {
V4(libc::sockaddr_in),
V6(libc::sockaddr_in6),
}
impl fmt::Debug for SockaddrInx {
fn fmt(&self, f: &mut fmt::F... | code_fim | hard | {
"lang": "rust",
"repo": "kotovalexarian/rustraceroute",
"path": "/src/sockaddr_inx.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> const IPV4_BIG_ENDIAN: u32 = 16_777_343;
const IPV6_BIG_ENDIAN: [u8; 16] =
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1];
const IPV4_ADDR: Ipv4Addr = Ipv4Addr::new(127, 0, 0, 1);
const IPV6_ADDR: Ipv6Addr = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1);
#[test]
fn sanity_std_n... | code_fim | hard | {
"lang": "rust",
"repo": "kotovalexarian/rustraceroute",
"path": "/src/sockaddr_inx.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod compat03as01;
pub use self::compat03as01::Compat;
#[cfg(feature = "sink")]
#[cfg_attr(docsrs, doc(cfg(feature = "sink")))]
pub use self::compat03as01::CompatSink;<|fim_prefix|>// repo: rust-lang/futures-rs path: /futures-util/src/compat/mod.rs
//! Interop between `futures` 0.1 and 0.3.
//!
//! This m... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/futures-rs",
"path": "/futures-util/src/compat/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/futures-rs path: /futures-util/src/compat/mod.rs
//! Interop between `futures` 0.1 and 0.3.
//!
//! This module is only available when the `compat` feature of this
//! library is activated.
mod executor;
pub use self::executor::{Executor01As03, Executor01CompatExt, Executor01Future};
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/futures-rs",
"path": "/futures-util/src/compat/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>:core::marker::Copy for ProviderAdcChannelMode {}
impl ::core::clone::Clone for ProviderAdcChannelMode {
fn clone(&self) -> Self {
*self
}
}<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /crates/deps/sys/src/Windows/Devices/Adc/Provider/mod.rs
#![allow(non_snake_case, non_camel_... | code_fim | hard | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/deps/sys/src/Windows/Devices/Adc/Provider/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /crates/deps/sys/src/Windows/Devices/Adc/Provider/mod.rs
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system<|fim_suffix|>dcChannelMode(pub i32);
impl Provide... | code_fim | medium | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/deps/sys/src/Windows/Devices/Adc/Provider/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>dcChannelMode(pub i32);
impl ProviderAdcChannelMode {
pub const SingleEnded: Self = Self(0i32);
pub const Differential: Self = Self(1i32);
}
impl ::core::marker::Copy for ProviderAdcChannelMode {}
impl ::core::clone::Clone for ProviderAdcChannelMode {
fn clone(&self) -> Self {
*self
... | code_fim | medium | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/crates/deps/sys/src/Windows/Devices/Adc/Provider/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r = Ray2D::new();
assert_eq!(r.dir, vec2(1.0, 0.0));
}
#[test]
fn it_get_the_reflection_vector(){
}
#[test]
fn it_get_the_refraction_vector(){
}
#[test]
fn it_calculate_the_fresnel_coeficient(){
}
#[test]
fn in_case_... | code_fim | hard | {
"lang": "rust",
"repo": "edap/nannou-sketches",
"path": "/ray2d/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> }
#[test]
fn in_case_of_an_intersection_with_a_segment_it_return_the_distance_to_it(){
let mut r = Ray2D::new();
r.dir = vec2(0.0, 1.0);
let start_segment = vec2(-1.0, 2.0);
let end_segment = vec2(1.0, 2.0);
let distance_to_intersection = r.intersect_seg... | code_fim | hard | {
"lang": "rust",
"repo": "edap/nannou-sketches",
"path": "/ray2d/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: edap/nannou-sketches path: /ray2d/src/lib.rs
#[allow(dead_code)]
use nannou::prelude::*;
#[derive(Debug, Copy, Clone)]
pub enum BoundingVolume {
Circle { position: Vec2, radius: f32 },
Aabb { min: Vec2, max: Vec2 },
}
#[derive(Debug, Clone, Copy)]
pub struct Ray2D {
pub orig: Vec2,... | code_fim | hard | {
"lang": "rust",
"repo": "edap/nannou-sketches",
"path": "/ray2d/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for row in bad {
println!("{:?}", row);
}
}
Ok(())
}<|fim_prefix|>// repo: jlmcmchl/poe-dat-rs path: /examples/parse-derive.rs
use std::{fs::File, io::Read};
fn main() -> Result<(), String> {
for path in glob::glob("G:\\POE\\Data\\AreaInfluenceDoodads.dat").unwrap... | code_fim | hard | {
"lang": "rust",
"repo": "jlmcmchl/poe-dat-rs",
"path": "/examples/parse-derive.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jlmcmchl/poe-dat-rs path: /examples/parse-derive.rs
use std::{fs::File, io::Read};
fn main() -> Result<(), String> {
for path in glob::glob("G:\\POE\\Data\\AreaInfluenceDoodads.dat").unwrap() {
let path = path.unwrap();
let mut file = File::open(path.as_path()).map_err(|err|... | code_fim | hard | {
"lang": "rust",
"repo": "jlmcmchl/poe-dat-rs",
"path": "/examples/parse-derive.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for row in good {
println!("{:?}", row);
}
for row in bad {
println!("{:?}", row);
}
}
Ok(())
}<|fim_prefix|>// repo: jlmcmchl/poe-dat-rs path: /examples/parse-derive.rs
use std::{fs::File, io::Read};
fn main() -> Result<(), String> {
... | code_fim | hard | {
"lang": "rust",
"repo": "jlmcmchl/poe-dat-rs",
"path": "/examples/parse-derive.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bluejekyll/tokio path: /tokio/src/task/harness.rs
fn core(&mut self) -> &mut Core<T> {
unsafe { &mut self.cell.as_mut().core }
}
}
impl<T, S> Harness<T, S>
where
T: Future,
S: Schedule,
{
/// Poll the inner future.
///
/// All necessary state checks and tra... | code_fim | hard | {
"lang": "rust",
"repo": "bluejekyll/tokio",
"path": "/tokio/src/task/harness.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bluejekyll/tokio path: /tokio/src/task/harness.rs
where
T: Future,
S: 'static,
{
pub(super) unsafe fn from_raw(ptr: *mut ()) -> Harness<T, S> {
debug_assert!(!ptr.is_null());
Harness {
cell: NonNull::new_unchecked(ptr as *mut Cell<T>),
_p: Ph... | code_fim | hard | {
"lang": "rust",
"repo": "bluejekyll/tokio",
"path": "/tokio/src/task/harness.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn do_cancel(mut self, res: Snapshot) {
use std::panic;
debug_assert!(!res.is_complete());
let cell = unsafe { &mut self.cell.as_mut() };
let header = &cell.header;
let core = &mut cell.core;
// Since we transitioned the task state to `canceled`, it w... | code_fim | hard | {
"lang": "rust",
"repo": "bluejekyll/tokio",
"path": "/tokio/src/task/harness.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug!(
"Copying src {} to bundle {}",
build.runnable.source.display(),
bundle_path.display()
);
project::rec_copy_excl(
&build.runnable.source,
&bundle_path,
false,
&[build.runnable.source.join("target")],
)?;
debug!("Copying tes... | code_fim | hard | {
"lang": "rust",
"repo": "sonos/dinghy",
"path": "/dinghy-lib/src/device.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> debug!(
"Copying exe {:?} to bundle {:?}",
&build.runnable.exe, bundle_exe_path
);
copy_and_sync_file(&build.runnable.exe, &bundle_exe_path).with_context(|| {
format!(
"Couldn't copy {} to {}",
&build.runnable.exe.display(),
&bundle_e... | code_fim | hard | {
"lang": "rust",
"repo": "sonos/dinghy",
"path": "/dinghy-lib/src/device.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sonos/dinghy path: /dinghy-lib/src/device.rs
use crate::errors::*;
use crate::project;
use crate::project::{rec_copy, Project};
use crate::utils::copy_and_sync_file;
use crate::Build;
use crate::BuildBundle;
use log::debug;
use std::fs;
use std::path::Path;
pub fn make_remote_app(project: &Proj... | code_fim | hard | {
"lang": "rust",
"repo": "sonos/dinghy",
"path": "/dinghy-lib/src/device.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DaseinPhaos/redirect path: /src/pipeline/ds.rs
// Copyright 2017 Dasein Phaos aka. Luxko
//
// 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://opensource.org/licenses/MIT>, at your
// op... | code_fim | hard | {
"lang": "rust",
"repo": "DaseinPhaos/redirect",
"path": "/src/pipeline/ds.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> StencilOpDesc{
fail: StencilOp::KEEP,
depth_fail: StencilOp::KEEP,
pass: StencilOp::KEEP,
func: ComparisonFunc::ALWAYS,
}
}
}
bitflags!{
#[repr(C)]
pub struct DepthWriteMask: u32 {
const ZERO = 0;
const ALL = 1;
... | code_fim | hard | {
"lang": "rust",
"repo": "DaseinPhaos/redirect",
"path": "/src/pipeline/ds.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> struct MyController {}
impl MyController {
pub fn index(request: Request) -> Response {
Response::no_content()
}
}
let route = Route::get("/test", MyController::index);
router.add_route(route);
assert_eq!(1, 1);
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-ravel/ravel",
"path": "/src/http/router.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-ravel/ravel path: /src/http/router.rs
use std::fmt::Debug;
use actix_web::web::{self, Data};
use async_trait::async_trait;
use sea_orm::ColumnTrait;
use crate::Application;
use super::{Request, Response};
// temp for now so I can build out the proper DX.
pub type Action = fn(Request) ->... | code_fim | hard | {
"lang": "rust",
"repo": "rust-ravel/ravel",
"path": "/src/http/router.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> actix_web::Route::new()
.method(actix_web::http::Method::GET)
.to(actix_handler)
}
}
#[derive(Debug, Clone)]
pub enum Method {
Options,
Get,
Post,
Put,
Delete,
Head,
Trace,
Connect,
Patch,
}
#[cfg(test)]
mod tests {
use crate::h... | code_fim | hard | {
"lang": "rust",
"repo": "rust-ravel/ravel",
"path": "/src/http/router.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod client;
mod error;
mod parser;
mod server;
mod simple_sublist;
mod sublist;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
println!("server start..");
let s: Server<TrieSubList> = Server::default();
s.start().await
}<|fim_prefix|>// repo: WangHoi/learnrustbynats path: /ser... | code_fim | easy | {
"lang": "rust",
"repo": "WangHoi/learnrustbynats",
"path": "/server/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: WangHoi/learnrustbynats path: /server/src/main.rs
#![feature(test)]
#![feature(hash_raw_entry)]
<|fim_suffix|>mod client;
mod error;
mod parser;
mod server;
mod simple_sublist;
mod sublist;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
println!("server start..");
let s:... | code_fim | medium | {
"lang": "rust",
"repo": "WangHoi/learnrustbynats",
"path": "/server/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xfhxfh1212/starcoin path: /rpc/api/src/miner.rs
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2
<|fim_suffix|> &self,
minting_blob: String,
nonce: u32,
extra: String,
) -> FutureResult<MintedBlockView>;
/// get current ... | code_fim | hard | {
"lang": "rust",
"repo": "xfhxfh1212/starcoin",
"path": "/rpc/api/src/miner.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
minting_blob: String,
nonce: u32,
extra: String,
) -> FutureResult<MintedBlockView>;
/// get current mining job
#[rpc(name = "mining.get_job")]
fn get_job(&self) -> FutureResult<Option<MintBlockEvent>>;
}<|fim_prefix|>// repo: xfhxfh1212/starcoin pat... | code_fim | medium | {
"lang": "rust",
"repo": "xfhxfh1212/starcoin",
"path": "/rpc/api/src/miner.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Get OpenWeather data for one week
async fn get_open_weather_week_t(city: &String) -> Result<Vec<f32>, reqwest::Error> {
match reqwest::get(&format!(
"https://api.openweathermap.org/data/2.5/forecast?q={}&cnt=40&appid={}",
city, OPEN_WEATHER_API_KEY
))
.await
{
Ok... | code_fim | hard | {
"lang": "rust",
"repo": "dkuanyshbaev/weather",
"path": "/src/weather.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dkuanyshbaev/weather path: /src/weather.rs
use crate::errors;
use crate::types::*;
// Kelvins to Celsius
const K_TEMP: f32 = 273.15;
// OpenWeather key
const OPEN_WEATHER_API_KEY: &str = "3747e0afa07e05391851a943d0a18237";
// Calculate avg temperature for one day
pub async fn day(city: &String... | code_fim | hard | {
"lang": "rust",
"repo": "dkuanyshbaev/weather",
"path": "/src/weather.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Second data sourse for one week data
async fn week_weather_source_2(city: &String) -> Result<Vec<f32>, warp::Rejection> {
match get_open_weather_week_t(city).await {
Ok(tv) => Ok(tv),
// TODO: convert error
Err(_error) => Err(warp::reject::custom(errors::OpenWeatherError)),
... | code_fim | hard | {
"lang": "rust",
"repo": "dkuanyshbaev/weather",
"path": "/src/weather.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct ExpirationUnlockConditionDto {
#[serde(rename = "type")]
pub kind: u8,
#[serde(rename = "returnAddress")]
pub return_address: AddressDto,
#[serde(rename = "unixTime")]
pub time... | code_fim | hard | {
"lang": "rust",
"repo": "iotaledger/bee",
"path": "/bee-block/src/output/unlock_condition/expiration.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iotaledger/bee path: /bee-block/src/output/unlock_condition/expiration.rs
// Copyright 2021-2022 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
use derive_more::From;
use crate::{address::Address, Error};
/// Defines a unix time until which only Address, defined in Address Unlock Condit... | code_fim | hard | {
"lang": "rust",
"repo": "iotaledger/bee",
"path": "/bee-block/src/output/unlock_condition/expiration.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
fn main() {
// Initialization of allocated memory
let new_stu: CStudent = Default::default();
println!("rust side print new_stu: {:?}", new_stu);
let box_new_stu = Box::new(new_stu);
let p_stu = Box::into_raw(box_new_stu);
unsafe {
fill_data(p_stu);
print_data(... | code_fim | hard | {
"lang": "rust",
"repo": "whoneed/rust-practice",
"path": "/ffi/example_09/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: whoneed/rust-practice path: /ffi/example_09/src/main.rs
use std::os::raw::{c_char, c_float, c_int};
#[repr(C)]
#[derive(Debug)]
pub struct CStudent {
pub num: c_int,
pub total: c_int,
pub name: [c_char; 20],
pub scores: [c_float; 3],
}
// Default constructor
impl Default for CS... | code_fim | medium | {
"lang": "rust",
"repo": "whoneed/rust-practice",
"path": "/ffi/example_09/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /* boolean isLowMemoryPlatform (); */
Method {
name: "isLowMemoryPlatform",
abi: "C",
params: &[Param { name: "_retval", ty: "*mut bool" }],
ret: "nsresult",
... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/bt/nsIMemory.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /bt/nsIMemory.rs
//
// DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIMemory.idl
//
{static D: &'static [Interface] = &[
<|fim_suffix|> /* boolean isLowMemoryPlatform (); */
Method {
... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/bt/nsIMemory.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jthelin/demikernel path: /tests/rust/sga.rs
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
//==============================================================================
// Imports
//==============================================================================
us... | code_fim | hard | {
"lang": "rust",
"repo": "jthelin/demikernel",
"path": "/tests/rust/sga.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Tests looped allocation and deallocation of scatter-gather arrays.
fn do_test_unit_sga_alloc_free_loop_tight(size: usize) -> Result<()> {
let libos_name: LibOSName = match LibOSName::from_env() {
Ok(libos_name) => libos_name.into(),
Err(e) => anyhow::bail!("{:?}", e),
};
le... | code_fim | hard | {
"lang": "rust",
"repo": "jthelin/demikernel",
"path": "/tests/rust/sga.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hajifkd/vector_realloc_test path: /rust/src/main.rs
//! This also causes error
//!
//! ```
//! fn hoge<'a>(v: &'a Vec<i64>) -> &'a i64 {
//! // Of course this is error
//! // &v[3]
//! // This is error as well
//! static A: i64 = 5;
//! &A
//! }
//!
//! #[allow(unused_variabl... | code_fim | hard | {
"lang": "rust",
"repo": "hajifkd/vector_realloc_test",
"path": "/rust/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut vec = vec![0i64; 10];
vec[0] = 1;
vec[1] = 1;
vec[2] = 1;
vec[3] = 1;
let vref = &vec[3];
println!("Before resize ref ptr: {:p}", vref);
let _vec_dummy = vec![0i64; 10];
// error!
vec.resize(100, 0);
println!("After resize ref ptr: {:p}", vref);
p... | code_fim | medium | {
"lang": "rust",
"repo": "hajifkd/vector_realloc_test",
"path": "/rust/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: agersant/polaris path: /src/app/lastfm.rs
use rustfm_scrobble::{Scrobble, Scrobbler};
use std::path::Path;
use user::AuthToken;
use crate::app::{
index::{Index, QueryError},
user,
};
const LASTFM_API_KEY: &str = "02b96c939a2b451c31dfd67add1f696e";
const LASTFM_API_SECRET: &str = "0f25a80ceef... | code_fim | hard | {
"lang": "rust",
"repo": "agersant/polaris",
"path": "/src/app/lastfm.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn scrobble(&self, username: &str, track: &Path) -> Result<(), Error> {
let mut scrobbler = Scrobbler::new(LASTFM_API_KEY, LASTFM_API_SECRET);
let scrobble = self.scrobble_from_path(track)?;
let auth_token = self.user_manager.get_lastfm_session_key(username)?;
scrobbler.authenticate_with_sess... | code_fim | hard | {
"lang": "rust",
"repo": "agersant/polaris",
"path": "/src/app/lastfm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn unlink(&self, username: &str) -> Result<(), Error> {
self.user_manager
.lastfm_unlink(username)
.map_err(|e| e.into())
}
pub fn scrobble(&self, username: &str, track: &Path) -> Result<(), Error> {
let mut scrobbler = Scrobbler::new(LASTFM_API_KEY, LASTFM_API_SECRET);
let scrobble = ... | code_fim | hard | {
"lang": "rust",
"repo": "agersant/polaris",
"path": "/src/app/lastfm.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn borrow(&self) -> Result<&Value<'v>, Error> {
match self {
Self::Here(v) => Ok(v),
Self::Moved => Err(Error::new(E::ValueMoved))
}
}
pub fn borrow_mut(&mut self) -> Result<&mut Value<'v>, Error> {
match self {
Self::Here(v) => Ok(v),
Self::Moved => Err(Error::new(E::ValueMoved)... | code_fim | hard | {
"lang": "rust",
"repo": "chom-parser/ir",
"path": "/src/eval/value.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let args = match data {
InstanceData::EnumVariant(index, args) => {
match ty.desc() {
ty::Desc::Enum(enm) => {
let variant = enm.variant(*index).unwrap();
write!(f, ".{}", variant.ident(context.id()))?;
},
_ => panic!("malformed value")
}
ar... | code_fim | hard | {
"lang": "rust",
"repo": "chom-parser/ir",
"path": "/src/eval/value.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chom-parser/ir path: /src/eval/value.rs
use std::fmt;
use source_span::{
Position,
Span,
Loc
};
use crate::{
Context,
Namespace,
Constant,
ty,
Pattern
};
use super::{
Lexer,
Stack,
error,
error::Desc as E,
Error,
frame::Reference
};
pub enum Output<'v> {
IO(&'v mut dyn std::io::W... | code_fim | hard | {
"lang": "rust",
"repo": "chom-parser/ir",
"path": "/src/eval/value.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chops76/AoC2017 path: /src/day3.rs
use std::time::Instant;
fn part1(num: i32) -> i32 {
let mut dir = 0;
let mut max_x = 0;
let mut max_y = 0;
let mut min_x = 0;
let mut min_y = 0;
let mut cur_x:i32 = 0;
let mut cur_y:i32 = 0;
for _ in 1..num {
let mut new_dir = dir;
match dir {
0... | code_fim | hard | {
"lang": "rust",
"repo": "chops76/AoC2017",
"path": "/src/day3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
pub fn main() {
let p1_timer = Instant::now();
let p1_result = part1(277678);
let p1_time = p1_timer.elapsed();
println!("Part 1: {}", p1_result);
println!("Part 1 Time: {:?}", p1_time);
let p2_timer = Instant::now();
let p2_result = part2(277678);
let p2_time = p2_timer.elapsed();
pri... | code_fim | hard | {
"lang": "rust",
"repo": "chops76/AoC2017",
"path": "/src/day3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut total = 0;
for i in -1..=1 {
for j in -1..=1 {
total += nums[(x + 100 + i) as usize][(y + 100 + j) as usize];
}
}
total
}
fn part2(num: i32) -> i32 {
let mut dir = 0;
let mut max_x = 0;
let mut max_y = 0;
let mut min_x = 0;
let mut min_y = 0;
let mut cur_x:i32 = 0;
let mut cur_y... | code_fim | hard | {
"lang": "rust",
"repo": "chops76/AoC2017",
"path": "/src/day3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut v1 = vec![0, 0, 1, 1, 1, 2, 2, 3, 3, 4];
assert_eq!(Solution::remove_duplicates(&mut v1), 5);
assert_eq!(&v1[0..5], &(vec![0, 1, 2, 3, 4][..]));
}
}<|fim_prefix|>// repo: pearzl/leetcode_rust path: /src/answer/q0026_remove_duplicates_from_sorted_array.rs
// q0026_remov... | code_fim | medium | {
"lang": "rust",
"repo": "pearzl/leetcode_rust",
"path": "/src/answer/q0026_remove_duplicates_from_sorted_array.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pearzl/leetcode_rust path: /src/answer/q0026_remove_duplicates_from_sorted_array.rs
// q0026_remove_duplicates_from_sorted_array
struct Solution;
impl Solution {
pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 {
if nums.len() <= 1 {
return nums.len() as i32;
... | code_fim | hard | {
"lang": "rust",
"repo": "pearzl/leetcode_rust",
"path": "/src/answer/q0026_remove_duplicates_from_sorted_array.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ykafia/rust_gpu_raytracer path: /src/graphics/scene.rs
use std::error::{self, Error};
use nalgebra::Vector3;
use ocl::{Buffer, OclPrm, ProQue, Result, prm::{Float2, Float3, Float4}};
use crate::util::read_file;
use super::{Camera, DirectionalLight, Plane, RenderInfo, Sphere, directional_light... | code_fim | hard | {
"lang": "rust",
"repo": "ykafia/rust_gpu_raytracer",
"path": "/src/graphics/scene.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
pub fn get_screen(&mut self) -> &Vec<u32> {
self.screen_buf.read(&mut self.screen).enq().unwrap();
&self.screen
}
pub fn update_spheres(&mut self) -> Result<()> {
self.spheres_buf.write(&self.spheres).enq()?;
Ok(())
}
pub fn add_sphe... | code_fim | hard | {
"lang": "rust",
"repo": "ykafia/rust_gpu_raytracer",
"path": "/src/graphics/scene.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arkoh/arkoh-cube3d path: /src/main/vertices.rs
use gl::types::GLfloat;
// Vertex data
pub static cube_begin: i32 = 0;
pub static cube_end: i32 = 108;
pub static vertices: [GLfloat, ..108] = [
// Cube 0 .. 108
-0.5,-0.5,-0.5,
-0.5,-0.5, 0.5,
-0.<|fim_suffix|>0.5,
0.5, 0.5... | code_fim | hard | {
"lang": "rust",
"repo": "arkoh/arkoh-cube3d",
"path": "/src/main/vertices.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>0.5,
0.5, 0.5, 0.5,
0.5,-0.5, 0.5,
0.5, 0.5, 0.5,
0.5, 0.5,-0.5,
-0.5, 0.5,-0.5,
0.5, 0.5, 0.5,
-0.5, 0.5,-0.5,
-0.5, 0.5, 0.5,
0.5, 0.5, 0.5,
-0.5, 0.5, 0.5,
0.5,-0.5, 0.5
];<|fim_prefix|>// repo: arkoh/arkoh-cube3d path: /src/main/vertices.rs
use gl::types::G... | code_fim | hard | {
"lang": "rust",
"repo": "arkoh/arkoh-cube3d",
"path": "/src/main/vertices.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut i = 1;
loop {
println!("Hello javaTpoint");
if i == 7 {
break;
}
i += 1;
}
}<|fim_prefix|>// repo: rustkas/rust_javatpoint path: /javatpoint_rust_src/control_statements/src/loop2.rs
/*
cargo run -p control_statements --bin loop2
cargo fmt --... | code_fim | easy | {
"lang": "rust",
"repo": "rustkas/rust_javatpoint",
"path": "/javatpoint_rust_src/control_statements/src/loop2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustkas/rust_javatpoint path: /javatpoint_rust_src/control_statements/src/loop2.rs
/*
cargo run -p control_statements --bin loop2
cargo fmt --verbose --package control_statements
*/
<|fim_suffix|> let mut i = 1;
loop {
println!("Hello javaTpoint");
if i == 7 {
... | code_fim | easy | {
"lang": "rust",
"repo": "rustkas/rust_javatpoint",
"path": "/javatpoint_rust_src/control_statements/src/loop2.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.