blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
9aa82a77d10c2f8e826aef619d50f6d1753ed6ee | Rust | iamsubhranil/rexpr | /src/eval.rs | UTF-8 | 1,527 | 3.640625 | 4 | [] | no_license | use crate::builtin::Builtin;
use crate::lexer::TokenType;
use crate::parser::Node;
pub fn eval(tree: &Node) -> f64 {
match tree {
Node::Literal(val) => *val,
Node::Operator(left, operator, right) => {
let leftval = eval(left.as_ref());
let rightval = eval(right.as_ref());
... | true |
6faf4a7d3117e26f70f4cac5946f5bac9760c55e | Rust | eugeneia/rush | /vendor/once_cell/src/imp_std.rs | UTF-8 | 9,758 | 3.140625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // There's a lot of scary concurrent code in this module, but it is copied from
// `std::sync::Once` with two changes:
// * no poisoning
// * init function can fail
use std::{
cell::{Cell, UnsafeCell},
marker::PhantomData,
panic::{RefUnwindSafe, UnwindSafe},
sync::atomic::{AtomicBool, AtomicUsize, ... | true |
cd2f512755d011a4f5b3cfd56b083478f851d1a4 | Rust | aspires/lucet | /lucet-idl/src/parser.rs | UTF-8 | 33,262 | 2.921875 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | use super::lexer::{Keyword, LexError, Lexer, LocatedError, LocatedToken, Token};
use super::types::{AtomType, Attr, Location};
use std::error::Error;
use std::fmt;
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum SyntaxDecl {
Struct {
name: String,
members: Vec<StructMember>,
attrs: Vec<Attr... | true |
0031cc31dd6c335609a0390e7645c3d696d41e4e | Rust | emgre/agc | /agc/src/cpu/mod.rs | UTF-8 | 12,406 | 3 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use registers::BranchRegister;
use crate::cpu::instructions::*;
use crate::cpu::registers::{AddressRegister, MemoryAddress, SequenceRegister};
use crate::memory::{ErasableStorage, FixedStorage, MemoryWord};
use crate::word::*;
mod control_pulses;
mod instructions;
mod registers;
#[derive(Debug, Copy, Clone, Eq, Part... | true |
c348084a5b1c0b3295abc5e69b07d31c6934351a | Rust | ticki/libstd | /src/fs.rs | UTF-8 | 11,723 | 2.734375 | 3 | [] | no_license | use core_collections::borrow::ToOwned;
use io::{self, BufRead, BufReader, Read, Error, Result, Write, Seek, SeekFrom};
use os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use mem;
use path::{PathBuf, Path};
use string::String;
use sys_common::AsInner;
use vec::Vec;
use syscall::{open, dup, close, fpath, fstat, f... | true |
fe023969113d9d4600c3a491ab4cc778166594c3 | Rust | Open-Source-Projects-2021/patternfly-yew-quickstart | /src/components/form.rs | UTF-8 | 2,813 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | use crate::{example, example::ExamplePage};
use patternfly_yew::*;
use yew::prelude::*;
pub struct FormExample {}
impl Component for FormExample {
type Message = ();
type Properties = ();
fn create(_props: Self::Properties, _link: ComponentLink<Self>) -> Self {
Self {}
}
fn update(&mut ... | true |
3b36b6a4310298b14cf5ded7e8f4d398d37afa02 | Rust | Raz-Hemo/SpaceWarSupreme | /src/engine/systems/static_skybox.rs | UTF-8 | 1,392 | 2.703125 | 3 | [] | no_license | use crate::engine::prelude::*;
use specs::ReadStorage;
use crate::engine::components::StaticSkyboxComponent;
pub struct StaticSkyboxSystem {
skybox: Option<String>,
last_multi_skybox_warning: Option<std::time::Instant>,
}
impl StaticSkyboxSystem {
pub fn new() -> StaticSkyboxSystem {
StaticSkyboxS... | true |
bedca2e143bccf053784b9e09c62ad6489b23bf0 | Rust | Amanieu/thread_local-rs | /src/cached.rs | UTF-8 | 4,451 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | #![allow(deprecated)]
use super::{IntoIter, IterMut, ThreadLocal};
use std::fmt;
use std::panic::UnwindSafe;
use std::usize;
/// Wrapper around [`ThreadLocal`].
///
/// This used to add a fast path for a single thread, however that has been
/// obsoleted by performance improvements to [`ThreadLocal`] itself.
#[deprec... | true |
bb1d6953882aac37920ac69fcb45854317e98d8a | Rust | RichardlL/flac | /src/utility/types.rs | UTF-8 | 7,444 | 3.203125 | 3 | [
"BSD-3-Clause"
] | permissive | use nom::{Err, IResult, Needed};
use std::io;
use std::io::Read;
use std::ptr;
use std::cmp;
use super::StreamProducer;
#[derive(Debug)]
pub enum ErrorKind {
IO(io::Error),
Incomplete(usize),
Continue,
EndOfInput,
Unknown,
}
/// Structure that hold a slice of bytes.
pub struct ByteStream<'a> {
offset: u... | true |
f48b160c1d257ac6e164d91a531313cf127aaffe | Rust | leondejong/rust-playground | /general/collections/src/tree.rs | UTF-8 | 8,172 | 3.375 | 3 | [
"Apache-2.0"
] | permissive | use chrono::prelude::*;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use std::collections::BTreeMap;
use std::default::Default;
cfg_if::cfg_if! {
if #[cfg(test)] {
fn now() -> DateTime<Utc> {
Utc.with_ymd_and_hms(1234, 5, 6, 7, 8, 9).unwrap()
}
} else {
... | true |
a66a8c5b68e00e9b4d5086e360a5722ca020a83d | Rust | cesarb/clear_on_drop | /src/hide.rs | UTF-8 | 3,063 | 3.1875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Prevent agressive code removal optimizations.
//!
//! The functions in this module "hide" a variable from the optimizer,
//! so that it believes the variable has been read and/or modified in
//! unpredictable ways, while in fact nothing happened.
//!
//! Inspired by/based on Linux kernel's `OPTIMIZER_HIDE_VAR`, whi... | true |
3f06e5814d0895143d6c0e5cdfe0803ed7a5d182 | Rust | kuviman/codevisual | /codevisual/src/asset/simple.rs | UTF-8 | 1,435 | 2.625 | 3 | [
"MIT"
] | permissive | use *;
pub struct SimpleAssetFuture<T> {
handle: Arc<Mutex<Option<Result<T, Error>>>>,
}
impl<T> SimpleAssetFuture<T> {
pub fn new() -> Self {
Self {
handle: Arc::new(Mutex::new(None)),
}
}
pub fn get_handle(&self) -> Arc<Mutex<Option<Result<T, Error>>>> {
self.hand... | true |
8b293ae96a544a5ba7a0096b228209ce603eaa67 | Rust | mbilker/kbinxml-rs | /kbinxml/src/error.rs | UTF-8 | 4,373 | 2.515625 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use std::io;
use std::num::{ParseFloatError, ParseIntError};
use std::result::Result as StdResult;
use quick_xml::Error as QuickXmlError;
use rustc_hex::FromHexError;
use snafu::Snafu;
use crate::byte_buffer::ByteBufferError;
use crate::encoding_type::EncodingError;
use crate::node_types::Stand... | true |
955062f933ef9702cb655250855638647c40e566 | Rust | dirvine/RustNN | /tests/xor.rs | UTF-8 | 877 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | #![feature(std_misc)]
extern crate nn;
use std::num::Float;
use nn::{NN, HaltCondition};
use std::time::Duration;
#[test]
fn xor_timed() {
// create examples of the xor function
let examples = [
(vec![0f64, 0f64], vec![0f64]),
(vec![0f64, 1f64], vec![1f64]),
(vec![1f64, 0f64], vec![1f6... | true |
2c6f3ba3994c5f65014a34a96b6f38073573ef07 | Rust | TehPers/AdventOfCode | /years/aoc2020/src/day03/main.rs | UTF-8 | 941 | 3.03125 | 3 | [
"MIT"
] | permissive | use anyhow::Context;
use std::io::{BufRead, BufReader};
const INPUT: &[u8] = include_bytes!("input.txt");
fn count_trees(lines: &Vec<String>, right: usize, down: usize) -> usize {
lines
.iter()
.step_by(down)
.enumerate()
.map(|(i, line)| line.as_bytes()[(i * right) % line.len()])
... | true |
d297c85f9b5cb24ac4302efa7910a9053314ff5d | Rust | tuplecats/docker-client | /src/image/create/request.rs | UTF-8 | 2,988 | 3.09375 | 3 | [
"MIT"
] | permissive |
#[derive(Default)]
pub struct RequestBuilder {
from_image: String,
from_src: String,
repo: String,
tag: String,
message: String,
platform: String
}
impl RequestBuilder {
pub fn new() -> RequestBuilder {
RequestBuilder::default()
}
pub fn image<T>(mut self, image: ... | true |
9c60f25d60fea6d659367c2cdae3051b981f8d02 | Rust | Pamplemousse/mathematical_expression_evaluation | /src/parser/mod.rs | UTF-8 | 7,274 | 3.640625 | 4 | [] | no_license | use tokenizer::token::*;
pub fn parse(tokens: Vec<Token>) -> Vec<Token> {
let mut ast: Vec<Token> = Vec::new();
let mut operator_stack: Vec<Token> = Vec::new();
for token in tokens {
match token {
Token::Literal(_) => ast.push(token),
Token::Operator(operator) => {
... | true |
142081df5dc75c6563bac17d12677bbbbc3f9f54 | Rust | jkremser/rustlings | /exercises/option/option1.rs | UTF-8 | 433 | 3.21875 | 3 | [
"MIT"
] | permissive | // option1.rs
// Make me compile! Execute `rustlings hint option1` for hints
// you can modify anything EXCEPT for this function's sig
fn print_number(maybe_number: Option<u16>) {
println!("printing: {}", maybe_number.unwrap());
}
fn main() {
print_number(Some(13));
print_number(Some(99));
let number... | true |
4d5a9979493c7be4e2c6941765c991412add5566 | Rust | AyeGill/heron | /examples/quickstart.rs | UTF-8 | 1,329 | 2.859375 | 3 | [
"MIT"
] | permissive | use bevy::prelude::*;
use heron::prelude::*;
#[bevy_main]
fn main() {
App::build()
.add_plugins(DefaultPlugins)
.add_plugin(PhysicsPlugin::default()) // Add the Heron plugin
.insert_resource(Gravity::from(Vec3::new(0.0, -300.0, 0.0))) // Define gravity
.add_startup_system(spawn.syst... | true |
0ab751f8d392eeb94309806a3ed9527e3a70e866 | Rust | angristan/rlxc | /src/lxc.rs | UTF-8 | 4,863 | 2.96875 | 3 | [] | no_license | //! Rust wrapper for `struct lxc_container`. Implements methods to control
//! containers.
use failure::*;
use std::ffi::CStr;
use std::ffi::CString;
use std::os::raw::{c_char, c_int};
use std::path::Path;
use std::ptr;
use std::time::Duration;
use crate::util::ffi::{AllocatedStringArrayIter, ToCString};
mod attach_... | true |
9dccce9d74973558dec4ed7ad8c25cc1480081e6 | Rust | seanwallawalla-forks/nushell | /crates/nu-command/src/commands/dataframe/melt.rs | UTF-8 | 3,121 | 2.859375 | 3 | [
"MIT"
] | permissive | use crate::{commands::dataframe::utils::parse_polars_error, prelude::*};
use nu_engine::WholeStreamCommand;
use nu_errors::ShellError;
use nu_protocol::{dataframe::NuDataFrame, Signature, SyntaxShape, Value};
use super::utils::convert_columns;
pub struct DataFrame;
impl WholeStreamCommand for DataFrame {
fn name... | true |
1dcb3c905ca12df54eb1933f4b8154581dc5a108 | Rust | dezuman/narm | /src/bitmanip.rs | UTF-8 | 3,104 | 3.6875 | 4 | [
"MIT"
] | permissive |
/// Bit manipulation helper functions for integer types
pub trait BitManipulation{
/// gets the value of the bit at the specified index
fn get_bit(&self, index: u8) -> bool;
/// sets the value of the bit at the specified index
fn set_bit(&mut self, index: u8, value: bool);
/// gets the value of th... | true |
e3513e005371ec4076b2d3302a8469ee419bf683 | Rust | peterallin/rideways | /sdl_input/src/control_state.rs | UTF-8 | 1,446 | 3.25 | 3 | [] | no_license | #[derive(Debug, Copy, Clone, Default)]
pub struct ControlState {
pub left: bool,
pub right: bool,
pub up: bool,
pub down: bool,
pub fire: bool,
}
impl ControlState {
pub fn new() -> Self {
ControlState {
left: false,
right: false,
up: false,
... | true |
caaecd4481920ba7231bebdf3c49ea15929582ca | Rust | prz23/zinc | /zinc-types/src/instructions/evaluation_stack/push.rs | UTF-8 | 1,172 | 3.203125 | 3 | [
"Apache-2.0"
] | permissive | //!
//! The `push constant` instruction.
//!
use std::fmt;
use num::BigInt;
use serde::Deserialize;
use serde::Serialize;
use crate::data::r#type::scalar::Type as ScalarType;
use crate::instructions::Instruction;
///
/// The `push constant` instruction.
///
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]... | true |
c3e266432c06ad60fc6b7e627ab73cf92719ab3d | Rust | ozankasikci/rust-music-theory | /src/chord/errors.rs | UTF-8 | 651 | 2.84375 | 3 | [
"MIT"
] | permissive | use crate::note::NoteError;
use std::error;
use std::fmt;
/// An error while parsing a chord.
#[derive(Debug, Clone)]
pub enum ChordError {
InvalidRegex,
}
impl fmt::Display for ChordError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Invalid Regex!")
}
}
impl error::Error f... | true |
805aaff103b7f0f2de559b87c6d0ac234ed1faf2 | Rust | shaddyshad/inable_nav | /src/parser/interface.rs | UTF-8 | 2,921 | 3.453125 | 3 | [] | no_license | use std::borrow::Cow;
use regex::Regex;
// tokens
#[derive(Debug, Eq, PartialEq)]
pub enum Token {
ParseError(Cow<'static, str>),
TagToken(Tag)
}
// token kinds
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
pub enum TagKind {
StartTag,
EndTag
}
#[derive(Debug, Eq, PartialEq)]
pub struct Attribut... | true |
a8c38f6d59853b036ed6e55dc4d39b3598230799 | Rust | llxzy/adventofcode2020 | /rust/src/day3.rs | UTF-8 | 988 | 3.453125 | 3 | [] | no_license | use std::fs::read_to_string;
fn count_trees(right: usize, down: usize, lines: &String) -> i64 {
let mut tree_count: i64 = 0;
let mut current_pos = 0;
let l: Vec<&str> = lines.lines().collect();
let length = l[0].len();
for i in (0..(l.len()-1)).step_by(down as usize) {
let new_pos = (curr... | true |
23a55de4919e049871a37d7ecebbba3f2a4f6eac | Rust | EmbarkStudios/rust-gpu | /crates/spirv-builder/src/depfile.rs | UTF-8 | 4,564 | 3.09375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Reading Makefile-style dependency files.
//! Taken with permission from <https://github.com/m-ou-se/ninj/blob/master/lib/depfile/mod.rs>
use raw_string::{RawStr, RawString};
use std::fs::File;
use std::io::{BufRead, BufReader, Error, ErrorKind, Read};
use std::mem::{replace, take};
use std::path::Path;
/// Read a... | true |
f6aacb79ee681fafe9bda40c83f7f28a74c0a73c | Rust | Azure/azure-sdk-for-rust | /services/mgmt/serialconsole/src/package_2018_05/models.rs | UTF-8 | 7,086 | 2.59375 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT",
"LGPL-2.1-or-later"
] | permissive | #![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::de::{value, Deserializer, IntoDeserializer};
use serde::{Deserialize, Serialize, Serializer};
use std::str::FromStr;
#[doc = "An error response from the service."]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Default)]
pub struct CloudErr... | true |
fc4dce424ed79e6437895ed6e3063f6fadfdaf28 | Rust | HelveticaScenario/wasm-sketches | /crate/src/sketches/erase2.rs | UTF-8 | 5,892 | 2.6875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::pico::*;
use crate::sketch::*;
use std::cell::RefCell;
use std::cmp;
pub struct Erase2 {
pub last_mouse: Option<Point>,
pub radius: i32,
pub count: u32,
}
impl Sketch for Erase2 {
fn new() -> Erase2 {
set_dimensions(1024, 1024);
set_target(0);
cls(0);
set_ta... | true |
a962213398e933eef616611b7be5b54e8bafd7b4 | Rust | Fanaen/web-tracing | /apps/wasm-module/src/wasm_api.rs | UTF-8 | 9,831 | 2.8125 | 3 | [
"MIT"
] | permissive | use wasm_bindgen::prelude::*;
use nalgebra_glm::Vec3;
use nalgebra_glm::sqrt;
use crate::pathtracer::camera::{Camera};
use crate::pathtracer::PathTracer;
use crate::utils::set_panic_hook;
use crate::pathtracer::material::LambertianMaterial;
use crate::pathtracer::hit::HitableShape;
use crate::pathtracer::math::saturate... | true |
ac1db22103c48c5d329041524e3863dc7146c7ce | Rust | sriniv27/rust-task-parser | /src/main.rs | UTF-8 | 1,105 | 3 | 3 | [] | no_license | #![allow(unused)]
use chrono::*;
use csv;
use serde::{Deserialize, Serialize};
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::process;
// The `record` string is a 6 element string where the elements are
// ordered as:
// ID,Status,Subject,CreatedOn,ModifiedOn,CompletedOn
// type Task ... | true |
c07db2df695cde0288c281dd50edb56188dd3f35 | Rust | PistonDevelopers/turbine | /reactive/src/ptr.rs | UTF-8 | 2,106 | 3.40625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Pointers to higher order structures.
use std::marker::PhantomData;
/// Points to bool.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct Bool(usize);
/// Points to a scalar.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub struct Point1<T>(pub(crate) usize, PhantomData<T>);
/// Points to a 2D point.
#[deriv... | true |
21eeb4ebce0bdfa2e3f70fe32d714d08e0384b0f | Rust | kaj/rsass | /rsass/tests/spec/core_functions/selector/nest/list.rs | UTF-8 | 3,544 | 2.546875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Tests auto-converted from "sass-spec/spec/core_functions/selector/nest/list.hrx"
#[allow(unused)]
fn runner() -> crate::TestRunner {
super::runner().with_cwd("list")
}
mod list {
#[allow(unused)]
use super::runner;
#[test]
fn test_final() {
assert_eq!(
runner().ok("a {b: s... | true |
bb3118124db3f70a5ab071c4a11f36b332c10395 | Rust | lightclient/nushell | /crates/nu-cli/src/commands/run_alias.rs | UTF-8 | 3,270 | 2.5625 | 3 | [
"MIT"
] | permissive | use crate::commands::classified::block::run_block;
use crate::commands::WholeStreamCommand;
use crate::prelude::*;
use derive_new::new;
use nu_errors::ShellError;
use nu_protocol::{hir::Block, ReturnSuccess, Signature, SyntaxShape};
#[derive(new, Clone)]
pub struct AliasCommand {
name: String,
args: Vec<Strin... | true |
9d0800813492d93e35047326c19447287bfca98f | Rust | AlephAlpha/rlifesrc | /lib/src/error.rs | UTF-8 | 836 | 2.875 | 3 | [
"MIT"
] | permissive | //! All kinds of errors in this crate.
use crate::cells::{Coord, State};
use ca_rules::ParseRuleError;
use displaydoc::Display;
use thiserror::Error;
/// All kinds of errors in this crate.
#[derive(Clone, Debug, PartialEq, Eq, Display, Error)]
pub enum Error {
/// Unable to set cell at {0:?}.
SetCellError(Coo... | true |
4c584fe6661c89861c9e28d14eff7d9d6301c04e | Rust | virtualgraham/wasm-graph-app | /src/graph/memstore/quadstore.rs | UTF-8 | 15,991 | 2.703125 | 3 | [] | no_license | use crate::graph::value::Value;
use crate::graph::refs::{Size, Ref, Namer, Content};
use crate::graph::iterator::{Shape, Null};
use crate::graph::quad::{QuadStore, Quad, Direction, Stats, Delta, IgnoreOptions, Procedure};
use std::rc::Rc;
use std::cell::RefCell;
use std::collections::HashMap;
use std::collections::BTr... | true |
7fb8ee3b1f71bbb43facc6c050f19f8d45d352de | Rust | Intrebute/MysteryParsing | /src/lib.rs | UTF-8 | 5,049 | 2.625 | 3 | [] | no_license | use std::collections::HashMap;
use indenty::{RoseTree, tree};
use nom::{
branch::alt,
bytes::complete::tag,
character::complete::{line_ending, not_line_ending, space0},
combinator::map,
IResult,
multi::many0,
sequence::terminated,
};
pub mod dialogue_action;
#[derive(Debug, PartialEq)]
pu... | true |
fb18747f2a0f44edd35fa6d13463fbb74668c320 | Rust | vnermolaev/trace | /examples/example_format.rs | UTF-8 | 345 | 2.921875 | 3 | [] | no_license | use trace::trace;
fn main() {
env_logger::init();
foo(1, 2);
}
#[trace(a = "received {:?}")]
fn foo(a: i32, b: i32) {
println!("I'm in foo!");
bar((a, b));
}
#[trace(res = "returning {:?}", disable(b))]
fn bar((a, b): (i32, i32)) -> i32 {
println!("I'm in bar!");
if a == 1 {
2
} ... | true |
b1247dbf11be9a641c06fc031a24de20f0bf9f8f | Rust | BurntSushi/rust-snappy | /src/bytes.rs | UTF-8 | 3,933 | 3.125 | 3 | [
"BSD-3-Clause"
] | permissive | use std::convert::TryInto;
use std::io;
/// Read a u16 in little endian format from the beginning of the given slice.
/// This panics if the slice has length less than 2.
pub fn read_u16_le(slice: &[u8]) -> u16 {
u16::from_le_bytes(slice[..2].try_into().unwrap())
}
/// Read a u24 (returned as a u32 with the most ... | true |
3e7b724f15491f20724ef2c93dbc2499ef163a42 | Rust | rschifflin/networking | /gudp/src/service/builder.rs | UTF-8 | 1,875 | 2.890625 | 3 | [] | no_license | use std::io;
use std::net::SocketAddr;
use clock::Clock;
use super::{Conf, Service};
// NOTE: If we had generic specialization, this would not need 2 separate structs
// NOTE: If we had a delegate pattern, we wouldnt have to have two identical impls
// Instead, we make two separate structs and macro-ize their share... | true |
16278d66a9e7779927f8873792859ae7799da97a | Rust | theseus-os/Theseus | /libs/debugit/src/lib.rs | UTF-8 | 1,217 | 3.296875 | 3 | [
"MIT"
] | permissive | //! Use debug printlns, without the trait bounds (using specialization to
//! find the right impl anyway).
#![no_std]
#![allow(incomplete_features)]
#![feature(specialization)]
#[cfg(test)]
#[macro_use] extern crate std;
use core::fmt;
/// Formats the given argument using its `Debug` trait definition
/// and retur... | true |
b1f25a87e7cc32540b61c9ef08966a563813054e | Rust | mitermayer/rsocket-rust | /rsocket/src/payload/setup.rs | UTF-8 | 3,308 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | use crate::frame::Setup;
use crate::utils::DEFAULT_MIME_TYPE;
use bytes::Bytes;
use std::time::Duration;
#[derive(Debug)]
pub struct SetupPayload {
m: Option<Bytes>,
d: Option<Bytes>,
keepalive: (Duration, Duration),
mime_m: Option<String>,
mime_d: Option<String>,
}
#[derive(Debug)]
pub struct Set... | true |
53c21d8fd7649f313089c74138a7791841b3ea21 | Rust | suclogger/leetcode-rust | /chapter_5/sort-colors/src/main.rs | UTF-8 | 568 | 3.28125 | 3 | [] | no_license | fn main() {
}
pub fn sort_colors(nums: &mut Vec<i32>) {
let mut l = 0;
let mut r = nums.len() - 1;
let mut idx = 0;
while idx <= r && r > 0 {
if nums[idx] == 2 {
Self::swap(nums, idx, r);
if r > 0 {
r-=1;
}
} else if nums[idx] == 0 {
... | true |
a1326e9190c567c0ed629df8bfed51f7c227acb3 | Rust | TyPR124/winping | /src/pinger.rs | UTF-8 | 10,686 | 2.71875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use winapi::{
shared::{
minwindef::TRUE,
ntdef::{HANDLE, NULL},
ws2def::AF_INET6,
ws2ipdef::SOCKADDR_IN6,
},
um::{
handleapi::INVALID_HANDLE_VALUE,
icmpapi::{
Icmp6CreateFile, Icmp6SendEcho2, IcmpCloseHandle, IcmpCreateFile, IcmpSendEcho,
... | true |
eec28ec9c362d4f0d0d45f22b9763b7e8d90998b | Rust | KanoczTomas/bitcoin_playground | /src/traits/gen_rand_u256.rs | UTF-8 | 945 | 3.09375 | 3 | [] | no_license | use crate::types::U256;
use rand::Rng;
//inspired by https://github.com/rust-num/num-bigint/blob/master/src/bigrand.rs
/// Trait to generate random U256 numbers
pub trait GenRandU256 {
/// Generate a random U256.
fn gen_u256(&mut self) -> U256;
/// Generate a random `U256` within the given range. The lowe... | true |
04bef5675553e4819d8ab7abc795024d1621da3f | Rust | tenx-tech/prost | /benches/varint.rs | UTF-8 | 2,953 | 2.765625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![feature(test)]
extern crate bytes;
extern crate prost;
extern crate test;
use bytes::IntoBuf;
use prost::encoding::{
decode_varint,
encode_varint,
encoded_len_varint,
};
macro_rules! varint_bench {
($encode_name:ident, $decode_name:ident, $encoded_len_name: ident, $encode:expr) => {
#[benc... | true |
ad249465f216c79cdfae119a97e164f0282c2585 | Rust | adam0000345/sentry-rustdemo | /src/test.rs | UTF-8 | 4,896 | 2.515625 | 3 | [] | no_license | extern crate actix_web;
extern crate sentry;
extern crate sentry_actix;
#[macro_use]
extern crate failure;
#[macro_use]
extern crate lazy_static;
use std::num::ParseIntError;
use std::env;
use std::collections::HashMap;
use sentry::integrations::failure::capture_error;
use sentry::{configure_scope, User};
use acti... | true |
2c372d0d915cb516ec8e6dc135a6fdc27b2d7091 | Rust | jazzay/tauri | /tauri/src/salt.rs | UTF-8 | 1,437 | 3.03125 | 3 | [
"CC-BY-NC-ND-4.0",
"MIT"
] | permissive | use std::sync::Mutex;
use lazy_static::lazy_static;
use uuid::Uuid;
use web_view::WebView;
struct Salt {
value: String,
one_time: bool,
}
lazy_static! {
static ref SALTS: Mutex<Vec<Salt>> = Mutex::new(vec![]);
}
pub fn generate() -> String {
let salt = Uuid::new_v4();
SALTS
.lock()
.expect("Failed... | true |
0ed73b1de5c45fe8f35e8130d00d0b93b2a3ce7d | Rust | pijamarda/project-euler | /src/main.rs | UTF-8 | 5,116 | 3.78125 | 4 | [] | no_license | /*
Project Euler Problems:
https://projecteuler.net
*/
fn main() {
println!("Project Euler");
/*
problem1(1000);
problem2(4000000);
problem3(600851475143);
problem4(56);
problem5(20);
*/
problem4(5677848);
}
/*
Multiples of 3 and 5
If we list a... | true |
d03f1fb1c67c5caff5a319067009b338ee7463a5 | Rust | bcourtine/tmdb-client-rs | /tests/movie_api_tests.rs | UTF-8 | 1,839 | 2.71875 | 3 | [] | no_license |
use tmdb_client::apis::client::APIClient;
#[test]
fn movie_by_id_should_give_results() {
let client = APIClient::new_from_env();
let result = client.movies_api().get_movie_details(19995, None, None, None);
let movie = result.expect("Error querying movie 19995 (Avatar)");
assert_eq!(movie.title, Some(... | true |
4c7e0e5aee6725db281d0f5ecf876e3e6bb82411 | Rust | YuhanLiin/msp430fr2355-quickstart | /src/gpio.rs | UTF-8 | 14,759 | 2.515625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::marker::PhantomData;
use msp430fr2355 as pac;
pub trait PmmExt {
fn freeze(self) -> Pmm;
}
pub struct Pmm(());
impl PmmExt for pac::PMM {
fn freeze(self) -> Pmm {
self.pm5ctl0.write(|w| w.locklpm5().locklpm5_0());
Pmm(())
}
}
pub trait GpioExt {
type Gpio;
fn constrain... | true |
dd0f01346d9f0bfe270e6ebf72065cf8d26da156 | Rust | gottstech/grinrelay | /src/broker/stomp/frame.rs | UTF-8 | 5,821 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | #![macro_use]
use bytes::BytesMut;
use rustc_serialize::hex::ToHex;
use serde::{Serialize, Serializer};
use std::fmt;
use std::fmt::Formatter;
use std::str::from_utf8;
use super::header::*;
use super::subscription::AckMode;
#[derive(Copy, Clone, Debug, Serialize)]
pub enum Command {
Send,
Subscribe,
Unsubscribe,
... | true |
2f883d48ac9e111cd61b9468229321bc8b25c2af | Rust | paxyqi/cs140e | /os/kernel/src/shell.rs | UTF-8 | 3,582 | 3.484375 | 3 | [] | no_license | //use std::path::{Path,PathBuf};
use stack_vec::StackVec;
use console::{kprint, kprintln, CONSOLE};
use std::str;
use std::io::Write;
/// Error type for `Command` parse failures.
#[derive(Debug)]
enum Error {
Empty,
TooManyArgs
}
/// A structure representing a single shell command.
struct Command<'a> {
a... | true |
fc8ebbc6c8b9dcd791e9d65dfa272d3314f35406 | Rust | ChrisMacNaughton/xfs-rs | /src/lib.rs | UTF-8 | 35,430 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | #![recursion_limit="100"]
#[macro_use]
extern crate nom;
use std::error;
use std::fmt;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::str::FromStr;
use self::nom::{le_u8, is_digit, space, newline};
#[cfg(test)]
mod tests {
use nom;
#[test]
fn it_parses_a_u32() {
let input = b"... | true |
86cb9aeb149a3cfd9dd529539ef7a2fd97d66db2 | Rust | mathw/adventofcode | /aoc2020/src/day6/mod.rs | UTF-8 | 1,715 | 3.390625 | 3 | [] | no_license | use crate::dayerror::DayError;
use std::collections::HashSet;
pub fn part1() -> Result<String, DayError> {
let answer = do_part1(include_str!("input.txt"));
Ok(format!("The answer is {}", answer))
}
pub fn part2() -> Result<String, DayError> {
let answer = do_part2(include_str!("input.txt"));
Ok(for... | true |
f11d13c59979f2759aa01001f6dc8afb2b1864f8 | Rust | HadrienG2/weave-parallel-benchmarks-rs | /src/bin/fib.rs | UTF-8 | 991 | 3.234375 | 3 | [] | no_license | fn fib(n: usize) -> usize {
if n < 2 {
return n;
}
let (x, y) =
if cfg!(feature = "idiomatic") {
// Idiomatic mode, use optimized Rayon path for the common-case
// scenario of binary fork-join parallelization
rayon::join(|| fib(n-1), || fib(n-2))
... | true |
336fcffe448b46dd2eefbdfb431aa6cbf07e9c0f | Rust | anderoo/game-of-life | /src/universe.rs | UTF-8 | 3,558 | 3.421875 | 3 | [] | no_license | use super::cell::{Cell, CellKind};
use std::fmt;
#[derive(Clone, PartialEq, Debug)]
pub struct Universe {
pub size: usize,
pub cells: Vec<Vec<Cell>>
}
impl fmt::Display for Universe {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for i in 0..self.size {
for j in 0..self.size {... | true |
f8b1eb816727f9784d0dd0d4ec762deee2c829a7 | Rust | esbraff/moonlight-lang | /src/parser.rs | UTF-8 | 5,711 | 3.421875 | 3 | [] | no_license | use expressions::Expression;
use tokens::TokenType;
use tokens::Token;
pub struct Parser<'a> {
pub input: &'a Vec<Token>,
pub output: Vec<Box<Expression>>,
position: usize,
lenght: usize
}
impl<'a> Parser<'a> {
pub fn new(input: &'a Vec<Token>) -> Parser {
Parser {
input: inpu... | true |
203986d5d31ee21636e65551882f1a82bad0c04e | Rust | rustasync/runtime | /src/net/udp.rs | UTF-8 | 14,207 | 3.59375 | 4 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! Asynchronous UDP bindings.
//!
//! To create a bi-directional UDP socket use [`UdpSocket::bind`]. Sending data from the socket is
//! done by using [`send_to`] which returns the [`SendTo`] future. Reading data from the socket is
//! done by using [`recv_from`] which returns the [`RecvFrom`] future.
//!
//! [`UdpSoc... | true |
3bc002fd563a6e3f5c744b3c30fd1e3632989fae | Rust | tailhook/nginx-config | /src/access.rs | UTF-8 | 1,357 | 2.734375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::net::IpAddr;
use combine::{Parser};
use combine::{choice};
use combine::error::StreamError;
use combine::easy::Error;
use ast::{Item, Source};
use helpers::{semi, ident, string};
use tokenizer::{TokenStream, Token};
fn parse_source<'a>(val: Token<'a>)
-> Result<Source, Error<Token<'a>, Token<'a>>>
{
... | true |
480b1772af8f8d135649b852eb74be8e9e2e82fa | Rust | haetze/DemoRust | /projects/schiffeversenken/src/main.rs | UTF-8 | 3,630 | 2.9375 | 3 | [] | no_license | mod data;
extern crate futures_await as futures;
#[macro_use]
extern crate tokio_core;
use std::{env, io};
use std::net::SocketAddr;
use futures::{Future, Poll};
use tokio_core::net::UdpSocket;
use tokio_core::reactor::Core;
struct Server {
socket: UdpSocket,
buf: Vec<u8>,
to_send: Option<(usize, Socket... | true |
503932c72ce6cb1aeb016e0774f942e22a912002 | Rust | wartyz/spectrum | /src/hardware.rs | UTF-8 | 2,783 | 3.03125 | 3 | [] | no_license | #![allow(non_snake_case)]
pub const ANCHO_PANTALLA_GB: usize = 160 * 2;
pub const ALTO_PANTALLA_GB: usize = 144 * 2;
pub const ANCHO_PANTALLA_Z80: usize = 0;
pub const ALTO_PANTALLA_Z80: usize = 0;
use crate::cpu::CPU;
use crate::procesador::PROCESADOR;
// Aqui se crean las iteraciones del hardware con la memoria ... | true |
2cca767cd3af9d032ddd1ee61ebae0aa70068b79 | Rust | cnsr/rust-snake | /src/lib/snake.rs | UTF-8 | 1,728 | 2.9375 | 3 | [] | no_license | use crate::lib::types::{Cell, SnakeHead, Grid, SnakeSegment, Food};
use crate::lib::grid_init;
extern crate rand;
use rand::Rng;
pub fn change_grid(mut grid: Grid, head: &SnakeHead, dimensions: (u32, u32)) -> Grid{
let color: Cell = Cell {
red: head.color.red,
green: head.color.green,
blue... | true |
6fd0b7fc0582e1b37808ee6481aee9fef1fd634d | Rust | RonaldColyar/RustOOPParadigmTest | /src/main.rs | UTF-8 | 1,150 | 3.5625 | 4 | [] | no_license |
struct User{
username : String ,
password : String,
display_name: String,
phone_number : String,
age : String
}
impl User{
// constructor
pub fn new(user:&str ,
password:&str ,
display_name:&str ,
pn:&str ,
age :&str)-> User{
... | true |
c94b604504157bc046abe9f36e1535588c2ae0e5 | Rust | maxtnuk/My_workspace | /rust/do_myself/sqrt/src/main.rs | UTF-8 | 135 | 3.015625 | 3 | [] | no_license | fn main() {
let a = 55.0_f64;
let b = 40.0_f64;
let result = a * a + b * b;
println!("result is {}", result.sqrt());
}
| true |
945466e3f183e6d66f17e37bde03231285a2c29e | Rust | kjn-void/advent-of-code-2019 | /src/day18/mod.rs | UTF-8 | 8,246 | 2.84375 | 3 | [
"MIT"
] | permissive | use super::vec2d::*;
use super::Solution;
use std::cmp::Ordering;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
type Walls = HashSet<Vec2D>;
type Map = HashMap<Vec2D, u32>;
type KeyDistMatrix = HashMap<u32, Vec<KeyDistance>>;
#[derive(Debug)]
struct Robot {
at_key: u32, // key the robot curre... | true |
8d18634be29e8396d34c9bb63f54c0195cc5ab79 | Rust | alan-signal/utils | /pkcs8/src/traits.rs | UTF-8 | 8,993 | 2.921875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Traits for parsing objects from PKCS#8 encoded documents
use crate::{PrivateKeyInfo, Result, SubjectPublicKeyInfo};
use core::convert::TryFrom;
#[cfg(feature = "alloc")]
use crate::{PrivateKeyDocument, PublicKeyDocument};
#[cfg(feature = "encryption")]
use {
crate::{EncryptedPrivateKeyDocument, EncryptedPriv... | true |
b989aecc9a5db5df9fae62259f64aa5f046ef36a | Rust | werner/bitprim-rust | /src/hash.rs | UTF-8 | 1,666 | 3.296875 | 3 | [] | no_license | use std::cmp::Ordering;
use hex_error::HexError;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[repr(C, packed)]
pub struct Hash {
pub hash: [u8; 32usize],
}
impl Hash {
/* For compatibility with opaque collection that needs a builder */
pub fn new(raw: Hash) -> Hash {
raw
}
... | true |
dfaa688d2a0f42c99415fd90cbc29c4e63763ad5 | Rust | Soveu/random | /rust/child/main.rs | UTF-8 | 677 | 2.765625 | 3 | [] | no_license | use std::io::{self, Read};
use std::process::{Command, Stdio};
use std::thread;
fn main() -> io::Result<()> {
let mut child = Command::new("./test")
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.stdin(Stdio::piped())
.spawn()?;
let mut outbuf = String::new();
let mut err... | true |
0d09ff715b8023760ef175ad6e7a47f5a4ab60f1 | Rust | tizianocolagrossi/RustEx | /esercizi/lifetimes2.rs | UTF-8 | 327 | 3.203125 | 3 | [] | no_license | // Fix the compilation error by changing the create_user function input to a slice string
fn create_user<'a>(name: &'a str) -> User {
User { name: name }
}
#[derive(Debug)]
struct User<'b> {
name: &'b str,
}
fn main (){
let user = create_user(&"test");
println!("{:?}",user);
... | true |
b597574cdb05f9bc2fedb21bbfbbe9e9e8aa2645 | Rust | gnoliyil/fuchsia | /src/graphics/lib/compute/rive-rs/src/dyn_vec.rs | UTF-8 | 1,471 | 2.75 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2021 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 std::{cell::RefCell, cmp::Ordering};
#[derive(Debug)]
pub struct DynVec<T> {
vec: RefCell<Vec<T>>,
}
impl<T> DynVec<T> {
pub fn new() -> Self... | true |
7132f76ffbd43df456bf51598bd87b48802996c4 | Rust | kabergstrom/lonely | /benches/ring.rs | UTF-8 | 3,707 | 2.90625 | 3 | [] | no_license | #![feature(test)]
extern crate test;
use lonely::HeapRing;
const ELEMENTS: usize = 100_000;
const NUM_PRODUCERS: usize = 4;
const ELEMENTS_PER_PRODUCER: usize = ELEMENTS / NUM_PRODUCERS;
#[bench]
fn ring_spsc(b: &mut test::Bencher) {
let buffer = HeapRing::<u32>::new(1_000);
let producer_buf = producer_thread... | true |
72e7e87416662f9c18df4de57ef5815494db2a7b | Rust | qbox/rust-sdk | /qiniu-c/src/upload_response.rs | UTF-8 | 5,362 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | use crate::utils::qiniu_ng_str_t;
use libc::{c_void, size_t};
use qiniu_ng::storage::uploader::UploadResponse;
use std::{
mem::transmute,
ptr::{copy_nonoverlapping, null_mut},
};
use tap::TapOps;
/// @brief 上传响应
/// @details
/// 上传响应实例对上传响应中的响应体进行封装,提供一些辅助方法。
/// 当 `qiniu_ng_upload_response_t` 使用完毕后,请务... | true |
450a09082700d3557e76c5f26305e1f234757fb2 | Rust | bahamas10/vsv | /src/commands/enable_disable.rs | UTF-8 | 1,599 | 2.609375 | 3 | [
"MIT"
] | permissive | /*
* Author: Dave Eddy <dave@daveeddy.com>
* Date: February 15, 2022
* License: MIT
*/
//! `vsv enable` and `vsv disable`.
use anyhow::{ensure, Result};
use yansi::{Color, Style};
use crate::config;
use crate::config::Config;
use crate::runit::RunitService;
/// Handle `vsv enable`.
pub fn do_enable(cfg: &Config... | true |
d403bead26789937cec73ea706e6abc3e5332587 | Rust | klasnordmark/advent-of-code | /day3/src/main.rs | UTF-8 | 4,078 | 3.5625 | 4 | [] | no_license | use std::io;
enum Direction {
Up,
Down,
Right,
Left,
}
#[derive(PartialEq)]
enum Orientation {
Clockwise,
Counterclockwise,
Colinear,
}
struct Segment {
dir: Direction,
length: u32,
}
#[derive(Clone, PartialEq, Copy)]
struct Point {
x: i32,
y: i32,
}
fn segments_from_lin... | true |
7edf43654063b1a7118d61c9ae203f405a051e75 | Rust | JoshFourie/fft-rs | /src/two_radix/node.rs | UTF-8 | 12,584 | 3.15625 | 3 | [
"MIT"
] | permissive | use num::Complex;
use crate::two_radix::butterfly;
#[derive(Debug, PartialEq)]
pub enum NodeError<'a>
{
Stage(usize, usize),
Index(usize, usize),
Twiddle(&'a mut DecimationNode),
Len(usize, usize),
}
impl<'a> NodeError<'a>
{
pub fn flip_node(node: &mut DecimationNode) {
if node.twiddle==t... | true |
c89837b680fa9df08fd0217c6195bc7b37be0c58 | Rust | darkwisebear/dorkfs | /src/utility/gitconfig.rs | UTF-8 | 11,512 | 2.859375 | 3 | [
"MIT"
] | permissive | use std::hash::{Hash, Hasher};
use std::borrow::{Cow, Borrow};
use std::mem::replace;
use std::collections::hash_map::{self, HashMap};
use std::path::PathBuf;
use std::io::{Read, BufReader, BufRead};
use std::env;
use std::str::FromStr;
use failure::{bail, format_err, Fallible};
use regex::Regex;
use lazy_static::lazy... | true |
e6c0a9dbf5ccbddf73168cdf0dc171ab4937b7b5 | Rust | uazu/qcell | /src/tlcell.rs | UTF-8 | 11,861 | 3.1875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::any::TypeId;
use std::cell::UnsafeCell;
use std::collections::HashSet;
use std::marker::PhantomData;
use super::Invariant;
std::thread_local! {
static SINGLETON_CHECK: std::cell::RefCell<HashSet<TypeId>> = std::cell::RefCell::new(HashSet::new());
}
struct NotSendOrSync(*const ());
/// Borrowing-owner o... | true |
99d7133a8b054427336d93de1d50bbae5011e90a | Rust | sagiegurari/duckscript | /duckscript_sdk/src/sdk/std/fs/cp/mod.rs | UTF-8 | 2,478 | 2.703125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-free-unknown"
] | permissive | use crate::utils::pckg;
use duckscript::types::command::{Command, CommandResult};
use fs_extra::dir;
use fsio::directory::create_parent;
use std::fs;
use std::path::Path;
#[cfg(test)]
#[path = "./mod_test.rs"]
mod mod_test;
#[derive(Clone)]
pub(crate) struct CommandImpl {
package: String,
}
impl Command for Comm... | true |
59ae2409acd67f9813f0b9193f76b3b8afc1b30f | Rust | DoumanAsh/yukikaze | /src/header/content_disposition.rs | UTF-8 | 16,006 | 3.453125 | 3 | [
"Apache-2.0"
] | permissive | use percent_encoding::{utf8_percent_encode, percent_decode_str};
use crate::utils::enc::HEADER_VALUE_ENCODE_SET;
use core::fmt;
use core::str::FromStr;
use std::error::Error;
#[derive(Debug)]
///Filename parameter of `Content-Disposition`
pub enum Filename {
///Regular `filename`
Name(Option<String>),
//... | true |
c8041aea4e22221aff28b9ff7ab4168881c90e17 | Rust | ocadaruma/redis-hyperminhash | /src/redis/dense.rs | UTF-8 | 1,097 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | use crate::hyperminhash::{RegisterVector, NUM_REGISTERS};
use super::dma::CByteArray;
use std::mem::size_of;
/// RegisterVector impl which stores registers as 16-bit integer array.
/// Each integer is stored in little endian.
pub struct DenseVector {
data: CByteArray,
}
impl DenseVector {
pub const SINGLE_REG... | true |
06ebdfe09aa4bcb8de1450a1d97441c430b455ee | Rust | Logicalshift/flowbetween | /cmdline/diag/src/console.rs | UTF-8 | 2,290 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | use flo_commands::*;
use tokio::fs;
use tokio::io::{stdout, stderr, AsyncWrite, AsyncWriteExt};
use futures::prelude::*;
use std::path::*;
///
/// Sends the command output to the console
///
pub fn run_console<InputStream>(command_output: InputStream) -> impl Future<Output=()>+Send
where InputStream: Stream<Item=Flo... | true |
f7f46a72fc116c9d1df9d04eadb7a9e636652d99 | Rust | munagekar/cp | /leetcode/00012.rs | UTF-8 | 1,729 | 3.5 | 4 | [] | no_license | // https://leetcode.com/problems/integer-to-roman/
// It Would have been a better idea to use a dictionary based lookup instead of the long function
impl Solution {
pub fn int_to_roman(mut num: i32) -> String {
let mut a = String::new();
let ms = num / 1000;
num = num % 1000;
let mut... | true |
cd34bc5bd57eeca47f665607bc33c19df5c88755 | Rust | bosley/OPAS | /Rust/coal/lang/tests/expressions.rs | UTF-8 | 837 | 2.515625 | 3 | [
"MIT"
] | permissive |
extern crate coal_lang;
#[test]
fn expressions () {
let code_chunks = vec![
r#"
unit main{
static module other {
def init() -> none {}
def give_42() -> int {
return 42;
}
}
static module main {
members {
pi: float = 3.14159;
}
def init() -> none {
local_... | true |
44a42e4aed728a71e04b880964c609c47ff02d61 | Rust | ndrsllwngr/aussieplusplus | /src/ast/op.rs | UTF-8 | 2,466 | 3.34375 | 3 | [] | no_license | use std::fmt::Display;
use crate::token::Kind;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum UnaryOp {
Bang,
Minus,
}
impl From<Kind> for Option<UnaryOp> {
fn from(kind: Kind) -> Self {
match kind {
Kind::Bang => Some(UnaryOp::Bang),
Kind::Minus => Some(UnaryOp::Minus)... | true |
11769aa5f74c1ffe5eef8383bd38d9391ddea7d7 | Rust | NyxCode/Penrose-Polygon-Generator | /impossible-polygon/src/utils.rs | UTF-8 | 5,064 | 3.578125 | 4 | [] | no_license |
use crate::types::*;
use std::f64::consts::PI;
use svg::Document;
use svg::node::element::Polygon;
/// `get_wrap` gets an element from a `Vec` at a specific index.
/// Instead of causing a 'index out of bounds' panic, the index is 'wrapped around',
/// so `vec![1, 2, 3].get_wrap(3)` returns `1`
pub trait GetWrapping<... | true |
3b18f8ed907637912c9b593bc479651838378e43 | Rust | katyo/literium | /rust/backend/src/third/traits.rs | UTF-8 | 751 | 2.59375 | 3 | [
"MIT"
] | permissive | use super::ThirdError;
use base::BoxFuture;
use std::borrow::Cow;
/// Third service interface
pub trait IsThirdService<S, A>: Sized {
/// The name of provider
///
/// Example: guthub, google, ...etc.
fn service_name(&self) -> Cow<str>;
/// Fetch user info
///
/// Get user profile from thir... | true |
18039f6a976d574f0670596b5a6d45fff7100d2a | Rust | gerritsangel/lapin | /src/executor.rs | UTF-8 | 2,706 | 2.875 | 3 | [
"MIT"
] | permissive | use crate::{thread::ThreadHandle, Result};
use async_task::Task;
use crossbeam_channel::{Receiver, Sender};
use parking_lot::Mutex;
use std::{fmt, future::Future, ops::Deref, pin::Pin, sync::Arc, thread::Builder as ThreadBuilder};
pub trait Executor: std::fmt::Debug + Send + Sync {
fn spawn(&self, f: Pin<Box<dyn F... | true |
775b75fcca2b889610e39c9ddfe73b3b86840d67 | Rust | itto-ki/atcoder | /ABC/028/B.rs | UTF-8 | 482 | 3.28125 | 3 | [] | no_license | fn read_string() -> String {
let mut input = String::new();
let _ = std::io::stdin().read_line(&mut input);
input.trim().to_string()
}
fn main() {
let s = read_string();
let mut rslt = [0; 6];
for c in s.chars() {
rslt[((c as u8) - ('A' as u8)) as usize] += 1;
}
for (i, val) in ... | true |
b02bb3df9b025a0dc6383ba3d36b5d1eb386e966 | Rust | crypto-forks/rebuild-ethereum-in-rust | /rs/src/util/mod.rs | UTF-8 | 3,173 | 3.125 | 3 | [
"LicenseRef-scancode-other-permissive"
] | permissive | use crate::account::Account;
use crate::blockchain::block::U256;
use crate::blockchain::blockchain::Blockchain;
use crate::interpreter::OPCODE;
use crate::store::state::State;
use crate::transaction::tx::Transaction;
use crate::transaction::tx_queue::TransactionQueue;
use itertools::Itertools;
use serde::{Deserialize,... | true |
628c92045fe4cae203f6c94f21b7063e8594d98e | Rust | MrFlynn/saltine | /src/main.rs | UTF-8 | 2,174 | 2.953125 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate clap;
mod crypt;
mod generator;
mod thread;
use std::fs::File;
use std::io::{prelude::*, BufReader};
static DEFAULT_ALPHABET: &'static str = &"abcdefghijklmnopqrstuvwxyz";
fn get_user_info(path: &str, username: &str) -> (String, String) {
let file = File::open(path).unwrap();
let r... | true |
638573b6e949edb87d8f30f434fd84abdc178c88 | Rust | simon-frankau/advent_of_code_2018 | /day20b/src/main.rs | UTF-8 | 10,835 | 3.453125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::collections::HashSet;
use std::io;
use std::io::Read;
use std::iter::Peekable;
use std::slice::Iter;
#[derive(Clone)]
enum Match {
Literal(char),
Alternation(Vec<Match>),
Concatenation(Vec<Match>),
}
impl std::fmt::Debug for Match {
fn fmt(&self, f: &mut std::fmt::... | true |
97885ac75129bd13ac285829de7e50685b568fc5 | Rust | DobromirM/rust-examples | /custom-future-test/src/main.rs | UTF-8 | 930 | 2.90625 | 3 | [] | no_license | use async_std::task;
use futures::task::{Context, Poll};
use std::future::Future;
use std::time::Duration;
use tokio::macros::support::Pin;
#[tokio::main]
async fn main() {
let str = HelloFuture::new(hello()).await;
println!("{}", str)
}
async fn hello() -> String {
task::sleep(Duration::from_secs(1)).aw... | true |
a2c6c451bc6b33bec2f92b79026a8f7d979d8851 | Rust | opp11/calcr | /src/lexer.rs | UTF-8 | 6,270 | 3.6875 | 4 | [
"MIT"
] | permissive | use std::str::Chars;
use std::iter::Peekable;
use errors::{CalcrResult, CalcrError};
use token::Token;
use token::TokVal::*;
use token::OpKind::*;
use token::DelimKind::*;
pub fn lex_equation(eq: &String) -> CalcrResult<Vec<Token>> {
let mut lexer = Lexer {
pos: 0,
iter: eq.chars().peekable(),
... | true |
47312686490d987bad2768aeaca02d2c00ffa248 | Rust | aylei/leetcode-rust | /src/solution/s0208_implement_trie_prefix_tree.rs | UTF-8 | 2,517 | 3.75 | 4 | [
"Apache-2.0"
] | permissive | /**
* [208] Implement Trie (Prefix Tree)
*
* Implement a trie with insert, search, and startsWith methods.
*
* Example:
*
*
* Trie trie = new Trie();
*
* trie.insert("apple");
* trie.search("apple"); // returns true
* trie.search("app"); // returns false
* trie.startsWith("app"); // returns true
* t... | true |
a610c77279e83975aa7ccdef6d737dee65441890 | Rust | CalliEve/boa | /boa_engine/src/syntax/parser/expression/primary/array_initializer/mod.rs | UTF-8 | 4,580 | 2.890625 | 3 | [
"MIT",
"Unlicense"
] | permissive | //! Array initializer parsing.
//!
//! More information:
//! - [MDN documentation][mdn]
//! - [ECMAScript specification][spec]
//!
//! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
//! [spec]: https://tc39.es/ecma262/#sec-array-initializer
#[cfg(test)]
mod tests;
use ... | true |
2004453afff8647ccc72d2d7ef85235983f5defa | Rust | cryptoJLee/anchor-escrow | /programs/escrow/src/lib.rs | UTF-8 | 10,585 | 2.796875 | 3 | [] | no_license | //! An example of an escrow program, inspired by PaulX tutorial seen here
//! https://paulx.dev/blog/2021/01/14/programming-on-solana-an-introduction/
//! This example has some changes to implementation, but more or less should be the same overall
//! Also gives examples on how to use some newer anchor features and CPI... | true |
3790165662a27b5abd680852b4efe8eff686bd2d | Rust | Insynia/zgog-io-server | /src/player/mod.rs | UTF-8 | 4,093 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | pub mod inventory;
use std::sync::{Arc, RwLock};
use uuid::Uuid;
use crate::coordinates::Coords;
use crate::map::valid_spawn;
use crate::player::inventory::Inventory;
/// Player struct
#[derive(Clone, Serialize, Deserialize)]
pub struct Player {
pub id: Uuid,
pub name: String,
pub position: Coords,
p... | true |
9ea48aead327727227712928f490277ce59e540c | Rust | Jakobzs/rs-cache | /src/lib.rs | UTF-8 | 4,471 | 3.09375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! [RuneScape](https://oldschool.runescape.com/) cache api for basic
//! and simple cache interactions.
//!
//! # Features
//!
//! Currently rs-cache only supports OSRS with the features listed below.
//! This crate also contains tools to help you with implementing your own cache
//! if the currently supplied cache ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.