text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> info!("ServerFactory received WebSocket shutdown request.");
let ev = NetRelay::Shutdown(std::usize::MAX);
if self.sender.send(ev).is_ok() {
info!("Sending 'StopAndExit' to core.")
}
}
}
pub enum Role {
Player(bool),
Spectator,
GameFull,
}<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "ChooChooShoe/rust-cardgame",
"path": "/src/server/ws_server.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dorucioclea/IsengardContract path: /mandos/src/value_interpreter.rs
use super::{context::*, functions::*, value_raw::*};
use num_bigint::{BigInt, BigUint, Sign};
use num_traits::identities::Zero;
const STR_PREFIXES: &[&str] = &["str:", "``", "''"];
const ADDR_PREFIX: &str = "address:";
const S... | code_fim | hard | {
"lang": "rust",
"repo": "dorucioclea/IsengardContract",
"path": "/mandos/src/value_interpreter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let clean = s.replace(&['_', ','][..], "");
if clean.starts_with("0x") || clean.starts_with("0X") {
let clean = &clean[2..];
return if clean.len() % 2 == 0 {
hex::decode(clean).unwrap()
} else {
let even_bytes = format!("0{}", clean);
hex... | code_fim | hard | {
"lang": "rust",
"repo": "dorucioclea/IsengardContract",
"path": "/mandos/src/value_interpreter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let parsed = parse_unsigned(s);
assert!(
parsed.len() <= length,
"representation of {} does not fit in {} bytes",
s,
length
);
let mut result = vec![0u8; length];
let offset = length - parsed.len();
if !parsed.is_empty() {
result[offset..].c... | code_fim | hard | {
"lang": "rust",
"repo": "dorucioclea/IsengardContract",
"path": "/mandos/src/value_interpreter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> POST_DELAY_R {
POST_DELAY_R::new(((self.bits >> 4) & 0x0f) as u8)
}
#[doc = "Bits 8:11 - If the EOF flag is set, controls the minimum amount of time between the current frame and the next frame (or SSEL deassertion if EOT). 0x0 = No additional time is inserted. 0x1 = 1 SPI clock time is i... | code_fim | hard | {
"lang": "rust",
"repo": "nickray/lpc55-pac",
"path": "/src/spi0/dly.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ck times are inserted."]
#[inline(always)]
pub fn pre_delay(&mut self) -> PRE_DELAY_W {
PRE_DELAY_W { w: self }
}
#[doc = "Bits 4:7 - Controls the amount of time between the end of a data transfer and SSEL deassertion. 0x0 = No additional time is inserted. 0x1 = 1 SPI clock time is... | code_fim | hard | {
"lang": "rust",
"repo": "nickray/lpc55-pac",
"path": "/src/spi0/dly.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nickray/lpc55-pac path: /src/spi0/dly.rs
#[doc = "Reader of register DLY"]
pub type R = crate::R<u32, super::DLY>;
#[doc = "Writer for register DLY"]
pub type W = crate::W<u32, super::DLY>;
#[doc = "Register DLY `reset()`'s with value 0"]
impl crate::ResetValue for super::DLY {
type Type = u... | code_fim | hard | {
"lang": "rust",
"repo": "nickray/lpc55-pac",
"path": "/src/spi0/dly.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn graph(&self) -> &Self::Graph
{
&**self
}
}
impl<G: Graph, D: DerefMut<Target = G>> GraphDerefMut for D
{
fn graph_mut(&mut self) -> &mut Self::Graph
{
&mut **self
}
}<|fim_prefix|>// repo: Emoun/graphene path: /src/core/deref_graph.rs
use crate::core::Graph;
use std::ops::{Deref, DerefMut};
... | code_fim | hard | {
"lang": "rust",
"repo": "Emoun/graphene",
"path": "/src/core/deref_graph.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Emoun/graphene path: /src/core/deref_graph.rs
use crate::core::Graph;
use std::ops::{Deref, DerefMut};
/// Trait for types that reference a graph type.
///
/// This is part of the ensurance system and should be implemented
/// by any type that is itself a graph, or any type that references one.... | code_fim | medium | {
"lang": "rust",
"repo": "Emoun/graphene",
"path": "/src/core/deref_graph.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
&**self
}
}
impl<G: Graph, D: DerefMut<Target = G>> GraphDerefMut for D
{
fn graph_mut(&mut self) -> &mut Self::Graph
{
&mut **self
}
}<|fim_prefix|>// repo: Emoun/graphene path: /src/core/deref_graph.rs
use crate::core::Graph;
use std::ops::{Deref, DerefMut};
/// Trait for types that referen... | code_fim | hard | {
"lang": "rust",
"repo": "Emoun/graphene",
"path": "/src/core/deref_graph.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(vals)
}
pub fn build_event(mut object: RawObject) -> Result<IbcEvent, EventError> {
match object.action.as_str() {
// Client events
"create_client" | ibc::ics02_client::msgs::create_client::TYPE_URL => Ok(IbcEvent::from(
ClientEvents::CreateClient::try_from(object)?... | code_fim | hard | {
"lang": "rust",
"repo": "nhhtrung/ibc-rs",
"path": "/relayer/src/event/rpc.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn build_event(mut object: RawObject) -> Result<IbcEvent, EventError> {
match object.action.as_str() {
// Client events
"create_client" | ibc::ics02_client::msgs::create_client::TYPE_URL => Ok(IbcEvent::from(
ClientEvents::CreateClient::try_from(object)?,
)),
... | code_fim | hard | {
"lang": "rust",
"repo": "nhhtrung/ibc-rs",
"path": "/relayer/src/event/rpc.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nhhtrung/ibc-rs path: /relayer/src/event/rpc.rs
use std::{collections::HashMap, convert::TryFrom};
use tendermint_rpc::event::{Event as RpcEvent, EventData as RpcEventData};
use ibc::ics02_client::events::NewBlock;
use ibc::ics02_client::height::Height;
use ibc::ics24_host::identifier::ChainId... | code_fim | hard | {
"lang": "rust",
"repo": "nhhtrung/ibc-rs",
"path": "/relayer/src/event/rpc.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/devices/bin/driver_tools/src/subcommands/i2c/args.rs
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
super::subcommands::{
ping::args... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/devices/bin/driver_tools/src/subcommands/i2c/args.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand, name = "i2c", description = "Perform reads and writes on an I2C device")]
pub struct I2cCommand {
#[argh(subcommand)]
pub subcommand: I2cSubCommand,
}
#[derive(FromArgs, Debug, PartialEq)]
#[argh(subcommand)]
pub enum I2cSubCommand {
Pi... | code_fim | medium | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/devices/bin/driver_tools/src/subcommands/i2c/args.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Start the runtime with the handler
fn main() -> anyhow::Result<()> {
Ok(lambda!(|req| respond(handler(req))))
}<|fim_prefix|>// repo: dimfeld/study-map path: /api/info.rs
use lib::{respond, RequestError, Response};
use now_lambda::{http::StatusCode, lambda, Request};
use serde::Deserialize;
use std:... | code_fim | hard | {
"lang": "rust",
"repo": "dimfeld/study-map",
"path": "/api/info.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dimfeld/study-map path: /api/info.rs
use lib::{respond, RequestError, Response};
use now_lambda::{http::StatusCode, lambda, Request};
use serde::Deserialize;
use std::io::Read;
#[derive(Deserialize)]
struct Qs {
book_id: String,
}
fn handler(req: Request) -> Result<Response, RequestError> {
... | code_fim | medium | {
"lang": "rust",
"repo": "dimfeld/study-map",
"path": "/api/info.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct DummyFrame {}
impl Frame for DummyFrame {
type Error = SwapBuffersError;
type TextureId = DummyTexture;
fn clear(&mut self, _color: [f32; 4]) -> Result<(), Self::Error> {
Ok(())
}
fn render_texture(
&mut self,
_texture: &Self::TextureId,
_m... | code_fim | hard | {
"lang": "rust",
"repo": "rezural/smithay",
"path": "/wlcs_anvil/src/renderer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn render_texture(
&mut self,
_texture: &Self::TextureId,
_matrix: cgmath::Matrix3<f32>,
_tex_coords: [Vector2<f32>; 4],
_alpha: f32,
) -> Result<(), Self::Error> {
Ok(())
}
}
pub struct DummyTexture {
width: u32,
height: u32,
}
impl Te... | code_fim | hard | {
"lang": "rust",
"repo": "rezural/smithay",
"path": "/wlcs_anvil/src/renderer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rezural/smithay path: /wlcs_anvil/src/renderer.rs
use std::cell::Cell;
use cgmath::Vector2;
use smithay::{
backend::{
allocator::dmabuf::Dmabuf,
renderer::{Frame, ImportDma, ImportShm, Renderer, Texture, Transform},
SwapBuffersError,
},
reexports::wayland_ser... | code_fim | hard | {
"lang": "rust",
"repo": "rezural/smithay",
"path": "/wlcs_anvil/src/renderer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ustclug/ustcmirror-images path: /homebrew-bottles/bottles-json/src/main.rs
use std::{
collections::HashSet,
fs::File,
io::{Read, Write},
path::{Path, PathBuf},
};
use clap::{Parser, ValueEnum};
use serde_json::Value;
mod structs;
use structs::*;
#[derive(ValueEnum, Clone)]
en... | code_fim | hard | {
"lang": "rust",
"repo": "ustclug/ustcmirror-images",
"path": "/homebrew-bottles/bottles-json/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let mut file = File::create(target.join(tmp_name.clone())).unwrap();
file.write_all(contents.as_bytes()).unwrap();
}
std::fs::rename(target.join(tmp_name), target.join(final_name)).unwrap();
Some(())
}
fn main() {
let cli = Cli::parse();
match cli.mode {
... | code_fim | hard | {
"lang": "rust",
"repo": "ustclug/ustcmirror-images",
"path": "/homebrew-bottles/bottles-json/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tmp_name = format!("{}.json.new", name);
let final_name = format!("{}.json", name);
let contents = serde_json::to_string(f).unwrap();
{
// is it the same as existing file?
// this is to avoid unnecessary file metadata modification
let mut existing = String::new... | code_fim | hard | {
"lang": "rust",
"repo": "ustclug/ustcmirror-images",
"path": "/homebrew-bottles/bottles-json/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "zkp-prover")]
pub mod recursive {
pub use crate::gadgets::recursive_input::RecursiveInputVar;
}
pub const DEFAULT_KEYS_PATH: &str = ".zkp";<|fim_prefix|>// repo: nimiq/core-rs-albatross path: /zkp-circuits/src/lib.rs
#[cfg(feature = "zkp-prover")]
mod blake2s;
#[cfg(feature = "zkp-p... | code_fim | medium | {
"lang": "rust",
"repo": "nimiq/core-rs-albatross",
"path": "/zkp-circuits/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nimiq/core-rs-albatross path: /zkp-circuits/src/lib.rs
#[cfg(feature = "zkp-prover")]
mod blake2s;
#[cfg(feature = "zkp-prover")]
pub mod circuits;
#[cfg(feature = "zkp-prover")]
pub(crate) mod gadgets;
pub mod metadata;
#[cfg(feature = "zkp-prover")]
pub mod setup;
#[cfg(feature = "test-setup"... | code_fim | medium | {
"lang": "rust",
"repo": "nimiq/core-rs-albatross",
"path": "/zkp-circuits/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconssharp/social/icon_hive.rs
pub struct IconHive {
props: crate::Props,
}
impl yew::Component for IconHive {
type Properties = crate::Props;
type Message = ();
fn create(props: Self::Properties, _: yew::prelude::ComponentLink<S... | code_fim | medium | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialiconssharp/social/icon_hive.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danbev/learning-rust path: /src/deref.rs
trait Dr {
type Target: ?Sized;
fn deref(self: &Self) -> &Self::Target;
}
#[derive(Debug)]
struct S {
nr: i32,
}
trait Print {
fn print(self: &Self);
}
impl Dr for S {
type Target = S;
fn deref(self: &Self) -> &Self {
&s... | code_fim | hard | {
"lang": "rust",
"repo": "danbev/learning-rust",
"path": "/src/deref.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Print for S {
fn print(&self) {
println!("Printing something");
}
}
fn main() {
println!("Deref example");
let s = S { nr: 18 };
println!("s: {:?}", s);
// Now lets use the deref operator
println!("s: {:?}", *(&s));
// Show that we can use the dot operator to... | code_fim | medium | {
"lang": "rust",
"repo": "danbev/learning-rust",
"path": "/src/deref.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Select the capture mode of channel 0.
pub fn cc0_capture_mode(&mut self, value: CaptureMode) -> &mut Self {
self.kind.capture_mode_0 = value;
self
}
/// Select the capture mode of channel 1.
pub fn cc1_capture_mode(&mut self, value: CaptureMode) -> &mut Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "proman21/samd-timer",
"path": "/src/config/samx5x.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: proman21/samd-timer path: /src/config/samx5x.rs
use core::marker::PhantomData;
use crate::config::*;
use crate::timer::{TC0_1, TC2_3};
#[cfg(not(feature = "samd51g19a"))]
use crate::timer::TC4_5;
use crate::target_device::tc0::RegisterBlock;
use crate::target_device::MCLK;
use crate::target_d... | code_fim | hard | {
"lang": "rust",
"repo": "proman21/samd-timer",
"path": "/src/config/samx5x.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dgront/BioShell path: /bioshell-pdb/tests/test_simple_geometric.rs
use bioshell_pdb::{PdbAtom, ResidueId, Structure};
use bioshell_pdb::calc::{distance};
#[allow(non_upper_case_globals)]
const pdb_2gb1: &str = include_str!("./test_files/2gb1.pdb");
<|fim_suffix|> let lines: Vec<_> = pdb_2g... | code_fim | medium | {
"lang": "rust",
"repo": "dgront/BioShell",
"path": "/bioshell-pdb/tests/test_simple_geometric.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let lines: Vec<_> = pdb_2gb1.split("\n").filter(|&l|l.starts_with("ATOM")).collect();
let atoms: Vec<PdbAtom> = lines.iter().map(|l| PdbAtom::from_atom_line(l)).collect();
let strctr = Structure::from_iterator(atoms.iter());
let ai = strctr.atom(&ResidueId::new("A", 14, " "), " CA ").unwra... | code_fim | medium | {
"lang": "rust",
"repo": "dgront/BioShell",
"path": "/bioshell-pdb/tests/test_simple_geometric.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rclayton-the-terrible/bitmanip-rust path: /src/count_digits_in_integer.rs
pub fn division_method(int: i64) -> u64 {
let mut num_digits: u64 = 0;
let mut dec_value: i64 = int;
while dec_value >= 1 {
num_digits += 1;
dec_value = dec_value / 10 as i64;
}
num_digi... | code_fim | medium | {
"lang": "rust",
"repo": "rclayton-the-terrible/bitmanip-rust",
"path": "/src/count_digits_in_integer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(4, log10_method(1234));
assert_eq!(10, log10_method(9812376542));
}
#[test]
fn test_recursive_method() {
assert_eq!(4, recursive_method(1234));
assert_eq!(10, recursive_method(9812376542));
}
#[test]
fn test_to_string_method() {
... | code_fim | hard | {
"lang": "rust",
"repo": "rclayton-the-terrible/bitmanip-rust",
"path": "/src/count_digits_in_integer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> use super::*;
#[test]
fn test_division_method() {
assert_eq!(4, division_method(1234));
assert_eq!(10, division_method(9812376542));
}
#[test]
fn test_log10_method() {
assert_eq!(4, log10_method(1234));
assert_eq!(10, log10_method(9812376542));
... | code_fim | medium | {
"lang": "rust",
"repo": "rclayton-the-terrible/bitmanip-rust",
"path": "/src/count_digits_in_integer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/associated-types/issue-85103.rs
#![feature(rustc_attrs)]
<|fim_suffix|>#[rustc_layout(debug)]
type Edges<'a, E> = Cow<'a, [E]>;
//~^ 6:1: 6:18: unable to determine layout for `<[E] as ToOwned>::Owned` because `<[E] as ToOwned>::Owned` cannot be normalized
fn main... | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/associated-types/issue-85103.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[rustc_layout(debug)]
type Edges<'a, E> = Cow<'a, [E]>;
//~^ 6:1: 6:18: unable to determine layout for `<[E] as ToOwned>::Owned` because `<[E] as ToOwned>::Owned` cannot be normalized
fn main() {}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/associated-types/issue-85103.rs
#![feature(rustc_attr... | code_fim | easy | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/associated-types/issue-85103.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mark-inderhees/aoc path: /rust/src/year2015/day21.rs
// 2015 Day 21
// https://adventofcode.com/2015/day/21
// --- Day 21: RPG Simulator 20XX ---
// Play a basic RPG game with attack and defensive points. Who dies?
// What is best equipment combo for cost?
use anyhow::Result;
use itertools::Ite... | code_fim | hard | {
"lang": "rust",
"repo": "mark-inderhees/aoc",
"path": "/rust/src/year2015/day21.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Try each weapon
for weapon in day.weapons.iter() {
// Try each armor (or zero armor)
for armor in day.armor.iter() {
let armor = vec![armor];
// Try ring combos (0 to 2)
for ring_len in 1..=2 {
for rings in day.rings.iter().co... | code_fim | hard | {
"lang": "rust",
"repo": "mark-inderhees/aoc",
"path": "/rust/src/year2015/day21.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/bindgen/ir/function.rs
d
=
>
"
C
-
unwind
"
}
;
s
.
fmt
(
f
)
}
}
impl
quote
:
:
ToTokens
for
Abi
{
fn
to_tokens
(
&
self
tokens
:
&
mut
proc_macro2
:
:
TokenStream
)
{
let
abi
=
self
.
to_string
(
)
;
tokens
.
append_all
(
quote
!
{
#
abi
}
)
... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/bindgen/ir/function.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/
/
For
non
-
CXCursor_FunctionDecl
visiting
the
cursor
'
s
children
/
/
is
the
only
reliable
way
to
get
parameter
names
.
let
mut
args
=
vec
!
[
]
;
cursor
.
visit
(
|
c
|
{
if
c
.
kind
(
)
=
=
CXCursor_ParmDecl
{
let
ty
=
Item
:
:
from_ty_or_ref
(
c
.
cur_type
(
)
c
None
ctx
)
;
let
name
=
c
.
spelling... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/bindgen/ir/function.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>h
.
.
.
/
/
/
/
https
:
/
/
bugs
.
llvm
.
org
/
show_bug
.
cgi
?
id
=
45919
args_from_ty_and_cursor
(
ty
&
cursor
ctx
)
}
else
{
args
}
}
}
;
let
(
must_use
mut
is_divergent
)
=
if
ctx
.
options
(
)
.
enable_function_attribute_detection
{
let
[
must_use
no_return
no_return_cpp
]
=
cursor
.
has_attrs
(
&
[... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/bindgen/ir/function.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<ValueHandle> for Gauge {
fn from(handle: ValueHandle) -> Self {
Self { handle }
}
}<|fim_prefix|>// repo: samrg472/metrics path: /metrics-runtime/src/data/gauge.rs
use crate::common::ValueHandle;
/// Proxy object to update a gauge.
pub struct Gauge {
handle: ValueHandle,
}
... | code_fim | medium | {
"lang": "rust",
"repo": "samrg472/metrics",
"path": "/metrics-runtime/src/data/gauge.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: samrg472/metrics path: /metrics-runtime/src/data/gauge.rs
use crate::common::ValueHandle;
/// Proxy object to update a gauge.
pub struct Gauge {
handle: ValueHandle,
}
<|fim_suffix|>impl From<ValueHandle> for Gauge {
fn from(handle: ValueHandle) -> Self {
Self { handle }
}
... | code_fim | medium | {
"lang": "rust",
"repo": "samrg472/metrics",
"path": "/metrics-runtime/src/data/gauge.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Perryvw/AdventOfCode path: /AoC-2021rs/src/day7.rs
use crate::aoc::AocSolution;
pub struct Day7;
impl AocSolution for Day7 {
fn data_path(&self) -> &str { "data/day7.txt" }
fn calculate(&self, input: &String) -> (String, String) {
let crabs: Vec<i32> = input.split(",").map(|... | code_fim | hard | {
"lang": "rust",
"repo": "Perryvw/AdventOfCode",
"path": "/AoC-2021rs/src/day7.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return crabs.iter().map(|c| (c - position).abs()).sum();
}
fn cost_total2(crabs: &Vec<i32>, position: i32) -> i64 {
return crabs.iter().map(|c| cost2((c - position).abs() as i64)).sum();
}
fn cost2(distance: i64) -> i64 {
return (distance * (distance + 1)) / 2;
}
fn binary_search_min<TRet>(... | code_fim | medium | {
"lang": "rust",
"repo": "Perryvw/AdventOfCode",
"path": "/AoC-2021rs/src/day7.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> translation: Option<String>,
to_language: Option<LanguageOptions>,
from_language: Option<LanguageOptions>,
initial_text: Option<String>)
-> Translation
{
return Translation {
translation: translation.unwrap_or_default(),
to_l... | code_fim | hard | {
"lang": "rust",
"repo": "weavc/topcoder-rust-workbook",
"path": "/rust/3-translations-lib/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: weavc/topcoder-rust-workbook path: /rust/3-translations-lib/src/lib.rs
extern crate tokio;
extern crate async_trait;
use std::fmt::Display;
pub mod deepl;
pub mod google;
#[async_trait::async_trait]
pub trait Translator {
async fn translate(&self, text: String, to_language: LanguageOption... | code_fim | hard | {
"lang": "rust",
"repo": "weavc/topcoder-rust-workbook",
"path": "/rust/3-translations-lib/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = client.translate(text, LanguageOptions::PL, None).await;
if result.is_err() {
panic!("Error was not expected")
}
let translation = result.ok().unwrap();
println!("{}", translation);
assert_eq!(expected, translation.transla... | code_fim | hard | {
"lang": "rust",
"repo": "weavc/topcoder-rust-workbook",
"path": "/rust/3-translations-lib/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: guydunton/rust-gb path: /src/gameboy/tests/or.rs
use crate::gameboy::{Flags, Gameboy, RegisterLabel16, RegisterLabel8};
#[test]
fn or_r8_test() {
let opcodes = vec![
(0xB0, RegisterLabel8::B),
(0xB1, RegisterLabel8::C),
(0xB2, RegisterLabel8::D),
(0xB3, Regis... | code_fim | hard | {
"lang": "rust",
"repo": "guydunton/rust-gb",
"path": "/src/gameboy/tests/or.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> gb.set_register_8(RegisterLabel8::A, 0);
gb.step_once();
assert_eq!(gb.get_flag(Flags::Z), true);
assert_eq!(gb.get_register_8(RegisterLabel8::A), 0);
// Check the reverse
gb.set_register_8(RegisterLabel8::A, 1);
gb.step_once();
assert_eq!(gb.get_flag(Flags::Z), false);... | code_fim | hard | {
"lang": "rust",
"repo": "guydunton/rust-gb",
"path": "/src/gameboy/tests/or.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Check the program counter & cycles
assert_eq!(gb.get_register_16(RegisterLabel16::ProgramCounter), 0x1);
assert_eq!(cycles, 4);
}
// Check that the zero flag is set if the result is zero
for (opcode, register) in &opcodes {
let mut gb = Gameboy::new(vec![*op... | code_fim | hard | {
"lang": "rust",
"repo": "guydunton/rust-gb",
"path": "/src/gameboy/tests/or.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DylanNelson99/RustLabs path: /Small Excersises/ex2.rs
fn main() {
let price: i32 = 10;
println! {"Original price: {} ", price};
println! {"Discounted price: {} ", calculate_price(price)};
}
<|fim_suffix|> if price % 2 == 0 {
return price - 10;
} else {
return ... | code_fim | easy | {
"lang": "rust",
"repo": "DylanNelson99/RustLabs",
"path": "/Small Excersises/ex2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if price % 2 == 0 {
return price - 10;
} else {
return price - 2;
}
}<|fim_prefix|>// repo: DylanNelson99/RustLabs path: /Small Excersises/ex2.rs
fn main() {
let price: i32 = 10;
println! {"Original price: {} ", price};
println! {"Discounted price: {} ", calculate_... | code_fim | easy | {
"lang": "rust",
"repo": "DylanNelson99/RustLabs",
"path": "/Small Excersises/ex2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vigdail/wizard-wars path: /wizardwars_shared/src/components/mod.rs
pub mod damage;
mod health;
use bevy::prelude::*;
use serde::{Deserialize, Serialize};
pub use health::Health;
#[derive(Serialize, Deserialize, Debug, Default, Copy, Clone, Eq, PartialEq, Hash)]
pub struct Uuid(pub u32);
#[de... | code_fim | medium | {
"lang": "rust",
"repo": "vigdail/wizard-wars",
"path": "/wizardwars_shared/src/components/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone)]
pub struct LifeTime {
pub timer: Timer,
}
impl LifeTime {
pub fn from_seconds(duration: f32) -> Self {
Self {
timer: Timer::from_seconds(duration, false),
}
}
}<|fim_prefix|>// repo: vigdail/wizard-wars path: /wizardwars_shared/src/componen... | code_fim | hard | {
"lang": "rust",
"repo": "vigdail/wizard-wars",
"path": "/wizardwars_shared/src/components/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Serialize, Deserialize, Debug, Copy, Clone, Default)]
pub struct Position(pub Vec3);
#[derive(Serialize, Deserialize, Debug, Copy, Clone)]
pub struct Dead;
#[derive(Serialize, Deserialize, Debug, Copy, Clone)]
pub struct Winner;
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, E... | code_fim | medium | {
"lang": "rust",
"repo": "vigdail/wizard-wars",
"path": "/wizardwars_shared/src/components/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust path: /Chapter 3/morechar.rs
// morechar.rs -- the char type and int type contrasted
use std::io;
use std::io::prelude::*;
use std::{char, u32};
<|fim_suffix|> // using the write!() to display a char constant
write!(stdout, "{}", ... | code_fim | hard | {
"lang": "rust",
"repo": "rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust",
"path": "/Chapter 3/morechar.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // using the write!() to display a char constant
write!(stdout, "{}", '!');
stdout.write(b"\nDone\n")?;
Ok(())
}<|fim_prefix|>// repo: rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust path: /Chapter 3/morechar.rs
// morechar.rs -- the char type and int type contrasted
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust",
"path": "/Chapter 3/morechar.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pzol/ustr path: /src/ustr/test.rs
#[feature(globs)];
extern crate ustr;
use ustr::*;
mod ustring;
mod ffi;
mod regex;
mod regex_test;
static FOOBAR: &'static str = "föobär";
#[test]
fn test_to_str(){
let u = FOOBAR.to_u();
assert_eq!(u.to_str(), ~"föobär");
}
#[test]
fn test_to_str_empt... | code_fim | hard | {
"lang": "rust",
"repo": "pzol/ustr",
"path": "/src/ustr/test.rs",
"mode": "psm",
"license": "ICU",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#[test]
fn test_concat(){
let u1 = "foo".to_u();
let u2 = "bar".to_u();
let combined = u1.concat(&u2);
assert_eq!(combined.to_str(), ~"foobar");
}
#[test]
fn test_split_str(){
let u = "foo bar".to_u();
let words = u.split_str(" ".to_u());
assert_eq!(words, ~["foo".to_u(), "bar".to_u()])... | code_fim | hard | {
"lang": "rust",
"repo": "pzol/ustr",
"path": "/src/ustr/test.rs",
"mode": "spm",
"license": "ICU",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn run_file_without_directory_provided() {
test::run_script_and_validate(
vec![create("")],
"out = dirname file.txt",
CommandValidation::None,
);
}<|fim_prefix|>// repo: sagiegurari/duckscript path: /duckscript_sdk/src/sdk/std/fs/dirname/mod_test.rs
use super::*;
u... | code_fim | hard | {
"lang": "rust",
"repo": "sagiegurari/duckscript",
"path": "/duckscript_sdk/src/sdk/std/fs/dirname/mod_test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> test::run_script_and_validate(
vec![create("")],
"out = dirname file.txt",
CommandValidation::None,
);
}<|fim_prefix|>// repo: sagiegurari/duckscript path: /duckscript_sdk/src/sdk/std/fs/dirname/mod_test.rs
use super::*;
use crate::test;
use crate::test::CommandValidation;... | code_fim | medium | {
"lang": "rust",
"repo": "sagiegurari/duckscript",
"path": "/duckscript_sdk/src/sdk/std/fs/dirname/mod_test.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sagiegurari/duckscript path: /duckscript_sdk/src/sdk/std/fs/dirname/mod_test.rs
use super::*;
use crate::test;
use crate::test::CommandValidation;
#[test]
fn common_functions() {
test::test_common_command_functions(create(""));
}
#[test]
fn run_no_path_provided() {
<|fim_suffix|>#[test]
fn... | code_fim | hard | {
"lang": "rust",
"repo": "sagiegurari/duckscript",
"path": "/duckscript_sdk/src/sdk/std/fs/dirname/mod_test.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bkfox/foxlive path: /libfoxlive/src/rpc/multiplex.rs
//! This modules provide structs that implements message multiplexing among multiple
//! receiver, that can either be used for any connection endpoint (client, server, ...).
//!
//! A Channel is the multiplexed transport's endpoint for a speci... | code_fim | hard | {
"lang": "rust",
"repo": "bkfox/foxlive",
"path": "/libfoxlive/src/rpc/multiplex.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// -- Channel
impl<S,R> Channel<S,R>
where S: Frame, R: Frame<Id=S::Id>,
{
fn new(id: Option<S::Id>, multiplex: Arc<RwLock<Multiplex<S,R>>>, queue: channel::Channel<mpsc::Sender<S>, MxReceiver<R>>, timeout: Option<Duration>) -> Self {
Self {
id, multiplex, queue,
t... | code_fim | hard | {
"lang": "rust",
"repo": "bkfox/foxlive",
"path": "/libfoxlive/src/rpc/multiplex.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Vicfred/codeforces-rust path: /beautifulyear.rs
// https://codeforces.com/problemset/problem/271/A
use std::collections::HashSet;
use std::io;
fn main() {
let mut year = String::new();
io::stdin().read_line(&mut year).unwrap();
let mut year: i64 = year.trim().parse().unwrap();
... | code_fim | medium | {
"lang": "rust",
"repo": "Vicfred/codeforces-rust",
"path": "/beautifulyear.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut characters = HashSet::new();
for ch in name.chars() {
characters.insert(ch);
}
if characters.len() == size {
println!("{}", name);
break;
}
}
}<|fim_prefix|>// repo: Vicfred/codeforces-rust path: /beautifulyear.rs
/... | code_fim | hard | {
"lang": "rust",
"repo": "Vicfred/codeforces-rust",
"path": "/beautifulyear.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.len() < 2 {
Err(Error::from(ErrorKind::InvalidInput))
} else {
Ok(args[1].clone())
}
}<|fim_prefix|>// repo: Rexagon/crypto-labs path: /lab1/src/stuff.rs
use std::io::{Error, ErrorKind};
<|fim_middle|>pub fn read_path() -> Result<String, Error> {
let args: Vec<Str... | code_fim | medium | {
"lang": "rust",
"repo": "Rexagon/crypto-labs",
"path": "/lab1/src/stuff.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rexagon/crypto-labs path: /lab1/src/stuff.rs
use std::io::{Error, ErrorKind};
<|fim_suffix|> if args.len() < 2 {
Err(Error::from(ErrorKind::InvalidInput))
} else {
Ok(args[1].clone())
}
}<|fim_middle|>pub fn read_path() -> Result<String, Error> {
let args: Vec<Str... | code_fim | medium | {
"lang": "rust",
"repo": "Rexagon/crypto-labs",
"path": "/lab1/src/stuff.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_best_unconfirmed(&self, maxsize: u32) -> PyTxs {
// get size limited unconfirmed tx's list
let chain = self.chain.lock().unwrap();
let hashs = chain.unconfirmed.get_best_unconfirmed_list(maxsize);
PyTxs::from_hash_vec(hashs.txs)
}
fn calc_next_bits(&mut ... | code_fim | hard | {
"lang": "rust",
"repo": "namuyan/bc4py_core",
"path": "/src/python/pyvalidate.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: namuyan/bc4py_core path: /src/python/pyvalidate.rs
use crate::block::{
bits_to_target,
target_to_bits,
target_to_diff,
BlockFlag,
DifficultyBuilder,
GenerateBuilder,
PocWorker,
PosWorker,
PowWorker,
RewardBuilder,
};
use crate::python::pyblock::{PyBlock, P... | code_fim | hard | {
"lang": "rust",
"repo": "namuyan/bc4py_core",
"path": "/src/python/pyvalidate.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn push_pow_worker(&mut self, flag: u8, power_limit: u8, block_ver: u32, tx_ver: u32) -> PyResult<()> {
let flag = BlockFlag::from_int(flag).map_err(|err| AssertionError::py_err(err))?;
let worker = PowWorker::new(&flag, power_limit, block_ver, tx_ver);
self.gene
.p... | code_fim | hard | {
"lang": "rust",
"repo": "namuyan/bc4py_core",
"path": "/src/python/pyvalidate.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mayone-du/rust_practice_minigrep path: /src/lib.rs
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
// コマンドライン引数
pub struct Config {
pub query: String,
pub filename: String,
}
// new関連関数を追加
impl Config {
// 引数で標準入力の引数を受け取り、Result型を返す
pub fn new(args: &[String]) -> Res... | code_fim | hard | {
"lang": "rust",
"repo": "mayone-du/rust_practice_minigrep",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 可変文字列を定義
let mut contents = String::new();
// ファイルの内容を↑の可変文字列にバインド
f.read_to_string(&mut contents)?;
// 検索し出力する
for line in search(&config.query, &contents) {
println!("{}", line);
}
// うまく行ったらResultのOkを返す
Ok(())
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn one_resu... | code_fim | hard | {
"lang": "rust",
"repo": "mayone-du/rust_practice_minigrep",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod test {
use super::*;
#[test]
fn one_result() {
let query = "duct";
// Rustは
// 安全で速く生産性も高い。
// 3つ選んで。
let contents = "\
Rust:
safe, fast, productive.
Pick three.";
assert_eq!(vec!["safe, fast, productive."], search(query, contents));
}
}
// ライフタイムを指定
pub... | code_fim | hard | {
"lang": "rust",
"repo": "mayone-du/rust_practice_minigrep",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut events = self.ctx.event_pump().unwrap();
for event in events.poll_iter() {
match event {
Event::Quit { .. }
| Event::KeyDown {
keycode: Some(Keycode::Escape),
..
} => {
... | code_fim | hard | {
"lang": "rust",
"repo": "squk/dorito-8",
"path": "/src/core/display/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: squk/dorito-8 path: /src/core/display/mod.rs
extern crate sdl2;
use sdl2::event::Event;
use sdl2::gfx::primitives::DrawRenderer;
use sdl2::image::LoadTexture;
use sdl2::keyboard::Keycode;
use sdl2::pixels::Color;
use sdl2::rect::{Point, Rect};
use sdl2::render::TextureCreator;
use std::path::Pa... | code_fim | hard | {
"lang": "rust",
"repo": "squk/dorito-8",
"path": "/src/core/display/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> // draw a pixel on the corner boundaries
self.draw_px(0, 0, white);
self.draw_px((self.width - 1) as i16, 0, green);
self.draw_px(0, (self.height - 1) as i16, red);
self.draw_px((self.width - 1) as i16, (self.height - 1) as i16, purple);
self.canvas.set_dra... | code_fim | hard | {
"lang": "rust",
"repo": "squk/dorito-8",
"path": "/src/core/display/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> while fi.advance() {
let (escave, bios, count): (String, String, usize) = fi.scan();
let mut cycles = Vec::with_capacity(count);
info!("Escave {} has {} cycles", escave, count);
for _ in 0..count {
fi.advance();
let cycle = {
let ... | code_fim | hard | {
"lang": "rust",
"repo": "kvark/vange-rs",
"path": "/src/config/bunches.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kvark/vange-rs path: /src/config/bunches.rs
use crate::config::text::Reader;
use serde_scan;
use std::fs::File;
#[derive(Debug, Deserialize)]
pub struct Cycle {
pub name: String,
pub cirt_max: usize,
pub radiance_time: usize,
pub price: usize,
pub palette_path: String,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "kvark/vange-rs",
"path": "/src/config/bunches.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ner;
mod utils;
pub use crate::config::WorkspaceSettings;
pub use crate::server::{LSPServer, ServerConnection, ServerFactory};<|fim_prefix|>// repo: Spread0x/rome path: /crates/rome_lsp/src/lib.rs
mod capabilities;
mod config;
mod documents;
mod handlers;
mod <|fim_middle|>line_index;
mod requests;
mod ... | code_fim | medium | {
"lang": "rust",
"repo": "Spread0x/rome",
"path": "/crates/rome_lsp/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Spread0x/rome path: /crates/rome_lsp/src/lib.rs
mod capabilities;
mod config;
mod documents;
mod handlers;
mod <|fim_suffix|>ner;
mod utils;
pub use crate::config::WorkspaceSettings;
pub use crate::server::{LSPServer, ServerConnection, ServerFactory};<|fim_middle|>line_index;
mod requests;
mod ... | code_fim | medium | {
"lang": "rust",
"repo": "Spread0x/rome",
"path": "/crates/rome_lsp/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>use crate::server::{LSPServer, ServerConnection, ServerFactory};<|fim_prefix|>// repo: Spread0x/rome path: /crates/rome_lsp/src/lib.rs
mod capabilities;
mod config;
mod documents;
mod handlers;
mod <|fim_middle|>line_index;
mod requests;
mod server;
mod session;
mod url_interner;
mod utils;
pub use crat... | code_fim | medium | {
"lang": "rust",
"repo": "Spread0x/rome",
"path": "/crates/rome_lsp/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut is_variant_func_name =
format_ident!("is_{}", variant_name.to_string().to_case(Case::Snake));
is_variant_func_name.set_span(variant_name.span());
variant_checker_functions.extend(quote_spanned! {variant.span()=>
... | code_fim | hard | {
"lang": "rust",
"repo": "MihirLuthra/is_variant",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>macro_rules! derive_error {
($string: tt) => {
Error::new(Span::call_site(), $string)
.to_compile_error()
.into();
};
}
#[proc_macro_derive(IsVariant)]
pub fn derive_is_variant(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveI... | code_fim | hard | {
"lang": "rust",
"repo": "MihirLuthra/is_variant",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MihirLuthra/is_variant path: /src/lib.rs
//! Generates methods to match enum variant.
//!
//! # Example
//!
//! ```rust
//! # macro_rules! dont_test { () => {
//! use is_variant::IsVariant;
//!
//! #[derive(IsVariant)]
//! enum TestEnum {
//! A,
//! B(),
//! C(i32, i32),
//! D {... | code_fim | hard | {
"lang": "rust",
"repo": "MihirLuthra/is_variant",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Latrasis/capnp_wrap path: /tests/simple.rs
#[macro_use]
extern crate capnp_wrap;
#[macro_use]
extern crate capnp;
pub mod simple_capnp {
include!(concat!(env!("OUT_DIR"), "/tests/simple_capnp.rs"));
}
<|fim_suffix|>#[derive(Schema)]
#[capnp(schema = "/tests/simple_capnp.rs")]
#[ca... | code_fim | easy | {
"lang": "rust",
"repo": "Latrasis/capnp_wrap",
"path": "/tests/simple.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn should_impl_hello_world() {
Person::noop();
}<|fim_prefix|>// repo: Latrasis/capnp_wrap path: /tests/simple.rs
#[macro_use]
extern crate capnp_wrap;
#[macro_use]
extern crate capnp;
pub mod simple_capnp {
include!(concat!(env!("OUT_DIR"), "/tests/simple_capnp.rs"));
}
trait... | code_fim | hard | {
"lang": "rust",
"repo": "Latrasis/capnp_wrap",
"path": "/tests/simple.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Manishearth/rust-encoding path: /src/encoding/index/iso_8859_8.rs
// AUTOGENERATED FROM index-iso-8859-8.txt, ORIGINAL COMMENT FOLLOWS:
//
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/
//
// For details on index-iso-8859-8.txt see the En... | code_fim | medium | {
"lang": "rust",
"repo": "Manishearth/rust-encoding",
"path": "/src/encoding/index/iso_8859_8.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Manishearth/rust-bindgen path: /src/hacks/refcell.rs
// Copyright 2012-2014 The Rust Project Developers.
// See http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | code_fim | hard | {
"lang": "rust",
"repo": "Manishearth/rust-bindgen",
"path": "/src/hacks/refcell.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn ge(&self, other: &RefCell<T>) -> bool {
*self.borrow() >= *other.borrow()
}
}
impl<T: ?Sized + Ord> Ord for RefCell<T> {
#[inline]
fn cmp(&self, other: &RefCell<T>) -> Ordering {
self.borrow().cmp(&*other.borrow())
}
}
struct BorrowRef<'b> {
borro... | code_fim | hard | {
"lang": "rust",
"repo": "Manishearth/rust-bindgen",
"path": "/src/hacks/refcell.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> use MyEnum::*; //~ ERROR unresolved import `MyEnum` [E0432]
//~| HELP a similar path exists
//~| SUGGESTION self::MyEnum
}
mod items {
enum Enum {
Variant
}
use Enum::*; //~ ERROR unresolved import `Enum` [E0432]
//~| HELP a ... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/unresolved/unresolved-import.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/unresolved/unresolved-import.rs
use foo::bar; //~ ERROR unresolved import `foo` [E0432]
//~^ maybe a missing crate `foo`?
use bar::Baz as x; //~ ERROR unresolved import `bar::Baz` [E0432]
//~| no `Baz` in `bar`
... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/unresolved/unresolved-import.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct System {
pub ibrav: Ibrav,
pub alat: f64,
pub ecutwfc: f64,
pub ecutrho: f64,
pub occupations: Occupations,
pub spin_type: Option<SpinType>,
}
/// Bravais lattice settings, given in the order they appear in the ... | code_fim | hard | {
"lang": "rust",
"repo": "tflovorn/qe-rs",
"path": "/src/pw/input.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tflovorn/qe-rs path: /src/pw/input.rs
use std::path::PathBuf;
use error;
/// Representation of the input file for Quantum Espresso 6.2.
///
/// The format is defined with the principle that "only valid states are representable".
/// However, some fields cannot be conveniently fully defined this... | code_fim | hard | {
"lang": "rust",
"repo": "tflovorn/qe-rs",
"path": "/src/pw/input.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn create_mad_lib(words: &WordTypes<'_>) -> String {
let mad_lib_template = "Do you VERB your ADJECTIVE NOUN ADVERB? That's hilarious!";
let mut output = mad_lib_template.replace("ADJECTIVE", words.adjective);
output = output.replace("VERB", words.verb);
output = output.replace("NOUN", ... | code_fim | medium | {
"lang": "rust",
"repo": "anontyro/rust-exercises-57",
"path": "/src/exercises/four/mad_libs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anontyro/rust-exercises-57 path: /src/exercises/four/mad_libs.rs
/**
* Exercise 4
* Mad libs are sinple games that require user input
* generally inputting of a noun, verb, adjective and adverb
* into a story
*
* example:
* Enter a noun: dog
* Enter a verb: walk
* Enter an adjective: bl... | code_fim | hard | {
"lang": "rust",
"repo": "anontyro/rust-exercises-57",
"path": "/src/exercises/four/mad_libs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let noun = get_user_input("Enter a noun".to_string());
let verb = get_user_input("Enter a verb".to_string());
let adjective = get_user_input("Enter an adjective".to_string());
let adverb = get_user_input("Enter an adverb".to_string());
let word_types = WordTypes {
noun: &noun,
... | code_fim | hard | {
"lang": "rust",
"repo": "anontyro/rust-exercises-57",
"path": "/src/exercises/four/mad_libs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sgeisler/gutenberg path: /components/rendering/src/markdown.rs
use std::borrow::Cow::{Owned, Borrowed};
use pulldown_cmark as cmark;
use self::cmark::{Parser, Event, Tag, Options, OPTION_ENABLE_TABLES, OPTION_ENABLE_FOOTNOTES};
use slug::slugify;
use syntect::easy::HighlightLines;
use syntect::... | code_fim | hard | {
"lang": "rust",
"repo": "sgeisler/gutenberg",
"path": "/components/rendering/src/markdown.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.