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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
73755756edc1f2f7364fee58da84ea5950164015 | Rust | kammitama5/9_14_16_RustDocumentationworkingthrough | /thirty_nine.rs | UTF-8 | 183 | 2.71875 | 3 | [] | no_license | fn main(){
fn take(v: Vec<i32>){
}
let v = vec![1, 2, 3];
//take(v);
println!("v[0] is: {}", v[0]);
println!("v[1] is: {}", v[1]);
println!("v[2] is: {}", v[2]);
} | true |
bddfa0dc4dd78c5faf7d65fbffedb39b83e9cdb1 | Rust | samsonjj/no-dependencies-blog | /src/main.rs | UTF-8 | 2,251 | 2.828125 | 3 | [] | no_license | extern crate http;
use http::*;
use std::path::PathBuf;
use std::fs;
use std::collections::HashSet;
fn not_found_response() -> HttpResponse {
let not_found_body = b"<h1>404 Not Found</h1>".to_vec();
HttpResponse::new(
HttpVersion::default(),
HttpStatusCode(404),
HttpHeaders::default(),... | true |
4909ebaa07df1ecd1ae2e32395e560be29898c4a | Rust | marco-c/gecko-dev-comments-removed | /third_party/rust/darling_core/src/error/mod.rs | UTF-8 | 19,607 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive |
use proc_macro2::{Span, TokenStream};
use std::error::Error as StdError;
use std::fmt;
use std::iter::{self, Iterator};
use std::string::ToString;
use std::vec;
use syn::spanned::Spanned;
use syn::{Expr, Lit, LitStr, Path};
#[cfg(feature = "diagnostics")]
mod child;
mod kind;
use crate::util::path_to_string;
... | true |
1c8fdf43407a37ce363c8cfd2ba8ddb25a688011 | Rust | JanErikVoigt/algorithmEngineeringTool | /src/main.rs | UTF-8 | 1,237 | 2.8125 | 3 | [] | no_license | use azul::prelude::*;
use azul::str::String as AzString;
use azul::widgets::{Button, Label};
struct DataModel {
counter: usize,
}
static CSS: AzString = AzString::from_const_str("
.__azul-native-label { font-size: 50px; }
");
extern "C" fn myLayoutFunc(data: &mut RefAny, _: LayoutCallbackInfo) -> StyledDom {... | true |
2c33f02e81d359b0869a4015cae8b464a4a38165 | Rust | kellpossible/coster | /costing/src/settlement.rs | UTF-8 | 1,183 | 3.09375 | 3 | [
"MIT"
] | permissive | use crate::error::CostingError;
use crate::tab::Tab;
use crate::user::UserID;
use chrono::NaiveDate;
use commodity::Commodity;
use doublecount::Transaction;
use serde::{Deserialize, Serialize};
/// Represents the settlement of a debt that one user owes another.
#[derive(Debug, Serialize, Deserialize)]
pub struct Sett... | true |
654cba86ad6849e0563d15e4f4bad99a0ba0d009 | Rust | jhessin/you-choose | /src/preview.rs | UTF-8 | 1,270 | 2.96875 | 3 | [] | no_license | use std::fmt;
use super::disp::DispFunc;
use super::screen::{Screen, ScreenSide};
pub struct Preview<D>
where
D: fmt::Display,
{
pub func: DispFunc<D>,
pub box_screen: Screen,
pub screen: Screen,
pub label: Option<String>,
}
impl<D> Preview<D>
where
D: fmt::Display,
{
pub fn new(func: DispFunc<D>, side... | true |
2c0fe75fc8e20002c04c7b59fac0a29a578c88f3 | Rust | wwylele/chocopy-rs | /chocopy-rs-std/src/lib.rs | UTF-8 | 6,883 | 2.640625 | 3 | [
"MIT"
] | permissive | use chocopy_rs_common::*;
use std::cell::*;
use std::mem::*;
use std::process::{abort, exit};
use std::ptr::*;
mod gc;
#[repr(transparent)]
#[derive(Clone, Copy)]
struct AllocUnit(u64);
thread_local! {
static INIT_PARAM: Cell<*const InitParam> = Cell::new(std::ptr::null());
static GC_HEAD: Cell<Option<NonNul... | true |
203eb56f9c9ed75699e9e2129d23f4faeea07456 | Rust | yehuohan/ln-misc | /rust/lnrust/src/book/generics/syntax.rs | UTF-8 | 587 | 4.125 | 4 | [] | no_license | //! 泛型基本语法
/// 泛型结构体
#[derive(Debug)]
pub struct Point<T> {
pub x: T,
pub y: T,
}
/// 泛型结构体的方法
impl<T> Point<T> {
pub fn get_x(&self) -> &T {
&self.x
}
pub fn get_y(&self) -> &T {
&self.y
}
}
/// 为f32实现的方法
impl Point<f32> {
pub fn len(&self) -> f32 {
(self.x.powi(2... | true |
07c61a93f7547c3f508b6fca56d82621c2b529aa | Rust | VaskillerDev/qdb-core | /src/memory/memory_machine.rs | UTF-8 | 9,981 | 3.21875 | 3 | [] | no_license | use crate::memory::compared::Compared;
use crate::memory::intersection::Intersection;
use qdb_ast::ast::types::DataType;
use rbtree::{Iter, RBTree};
use std::borrow::{BorrowMut, Cow};
use std::cmp::Ordering;
use std::collections::{BTreeMap, HashSet};
use std::ops::RangeInclusive;
pub type Indexes = Vec<RangeInclusive<... | true |
9bfd4750120bef62e7451e86728b344c727b8749 | Rust | benbrunton/rusteroids | /src/spaceship.rs | UTF-8 | 9,645 | 3.109375 | 3 | [
"MIT"
] | permissive | use actor::Actor;
use actor::ActorView;
use actor;
use messages::PlayerInstructions;
use messages::GameInstructions;
use rand;
use rand::Rng;
static PI : f32 = 3.14159265359;
static SHIELD_TIME: usize = 180;
static SHOW_TRAILS: bool = false;
#[derive(Debug, Clone, PartialEq)]
pub struct Spaceship{
id: i32,
x:... | true |
d51522e42d1b45f932e36f8d885991ab614677b4 | Rust | RustPython/RustPython | /vm/src/builtins/function/jitfunc.rs | UTF-8 | 6,942 | 2.765625 | 3 | [
"CC-BY-4.0",
"MIT"
] | permissive | use crate::{
builtins::{bool_, float, int, PyBaseExceptionRef, PyDictRef, PyFunction, PyStrInterned},
bytecode::CodeFlags,
convert::ToPyObject,
function::FuncArgs,
AsObject, Py, PyObject, PyObjectRef, PyResult, TryFromObject, VirtualMachine,
};
use num_traits::ToPrimitive;
use rustpython_jit::{AbiVa... | true |
ea85758ee885f3205137522c196368f55dd8f26e | Rust | obsidiansystems/ckb | /script/src/types.rs | UTF-8 | 1,934 | 3.28125 | 3 | [
"MIT"
] | permissive | use ckb_types::packed::Script;
use serde::{Deserialize, Serialize};
use std::fmt;
/// A script group is defined as scripts that share the same hash.
///
/// A script group will only be executed once per transaction, the
/// script itself should check against all inputs/outputs in its group
/// if needed.
pub struct Sc... | true |
1bc5163aa9bda1979b8162dbc7ca7841dac0bce2 | Rust | steveklabnik/rust-socks | /src/configuration.rs | UTF-8 | 1,357 | 3.046875 | 3 | [] | no_license | use std::io::File;
use std::io::BufferedReader;
use std::io::net::ip::{IpAddr, Ipv4Addr, SocketAddr};
pub struct Configuration {
pub whitelisted_ips: Vec<IpAddr>,
pub listen_ip: String,
pub listen_port: u16,
}
impl Configuration {
pub fn new(filename: Path) -> Configuration {
let file = match ... | true |
8dcdf890440ecd05286869024e45d21b5201ba3f | Rust | nikhilkalige/adventofcode | /src/aoc2019/day07/src/main.rs | UTF-8 | 5,630 | 2.953125 | 3 | [] | no_license | use intcode::{processor, simple_processor};
use itertools::Itertools;
use std::io::{self};
use std::sync::mpsc::channel;
use std::thread;
fn main() -> io::Result<()> {
let input = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/input/input.txt"));
let opcodes: Vec<i64> = input
.trim()
.split... | true |
ceccfc1ff506e283a10b4b27e9a135c523ef6e2f | Rust | nguyenminhhieu12041996/casper-node | /execution_engine_testing/cargo_casper/tests/integration_tests.rs | UTF-8 | 2,822 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | use std::{fs, process::Output};
use assert_cmd::Command;
use once_cell::sync::Lazy;
const FAILURE_EXIT_CODE: i32 = 101;
const SUCCESS_EXIT_CODE: i32 = 0;
const TEST_PATH: &str = "test";
static WORKSPACE_PATH_ARG: Lazy<String> =
Lazy::new(|| format!("--workspace-path={}/../../", env!("CARGO_MANIFEST_DIR")));
#[t... | true |
d74ac5f52457c2b45db6385804e401e4558c4648 | Rust | thled/rn | /app/src/config.rs | UTF-8 | 355 | 3.03125 | 3 | [
"MIT"
] | permissive | pub struct Config {
pub source: String,
pub new_name: String,
}
impl Config {
pub fn new(args: &[String]) -> Result<Config, &'static str> {
if args.len() < 3 {
return Err("not enough arguments");
}
Ok(Config {
source: args[1].clone(),
new_name: a... | true |
664d713c0b77fbee21b710b71dfcffc65b2d256e | Rust | prisma/prisma-engines | /query-engine/request-handlers/src/protocols/graphql/protocol_adapter.rs | UTF-8 | 10,175 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive | use crate::HandlerError;
use bigdecimal::{BigDecimal, FromPrimitive};
use graphql_parser::query::{
Definition, Document, OperationDefinition, Selection as GqlSelection, SelectionSet, Value,
};
use query_core::query_document::*;
/// Protocol adapter for GraphQL -> Query Document.
///
/// GraphQL is mapped as follow... | true |
301ddcf19e3deda2c18f03699e253f8948cb3ad6 | Rust | chandero/patternfly-yew | /src/clipboard.rs | UTF-8 | 6,528 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | use std::time::Duration;
use wasm_bindgen::prelude::*;
use yew::prelude::*;
use yew::services::{Task, TimeoutService};
use crate::button::*;
use crate::form::*;
use crate::icon::*;
use crate::*;
use yew::web_sys::{Element, HtmlInputElement};
#[derive(Clone, PartialEq, Properties)]
pub struct Props {
#[prop_or_def... | true |
b2fd48beee4f59b6b9db392ddd953477a51a14b5 | Rust | rust-rosetta/rust-rosetta | /tasks/md5/implementation/src/main.rs | UTF-8 | 6,195 | 2.8125 | 3 | [
"Unlicense"
] | permissive | //! Ported from C - Simple MD5 implementation
//! on Wikipedia: <https://en.wikipedia.org/wiki/MD5>
use std::fmt::{Debug, Formatter, Result};
use std::num::Wrapping as wr;
fn main() {
let inputs = [
&b"a"[..],
&b"abc"[..],
&b"message digest"[..],
&b"abcdefghijklmnopqrstuvwxyz"[..],... | true |
4e106fa57962b7510e10f66da0695f7b7cc18dc7 | Rust | dsbrgg/rust-book | /looping/src/main.rs | UTF-8 | 1,396 | 4.25 | 4 | [] | no_license | // -----------------------------------------------------------------
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// ------------------ Looping ---------------------------------
// Rust has three kinds of loops: loop, while and for.
// loop: will run infinitely, unless a break statement is made.... | true |
dc33dbee060cfba821a78a310e33686bafd4bad7 | Rust | sgrowe/advent-of-code-2020 | /src/day_ten.rs | UTF-8 | 3,812 | 3.421875 | 3 | [] | no_license | use super::utils::{parse_ints, start_day};
use std::collections::HashMap;
pub fn main() {
let input = start_day("ten");
let ints: Vec<usize> = parse_ints(&input).collect();
let adapters = Adapters::from_ratings(&ints);
println!("Part one: {}", part_one(&adapters));
println!("Part two: {}", part_... | true |
129921d7fe88bac72c0eb5ec713a291e94b5b789 | Rust | jolestar/libra | /crypto/crypto-derive/src/lib.rs | UTF-8 | 16,799 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
#![forbid(unsafe_code)]
//! # Derive macros for crypto operations
//! This crate contains four types of derive macros:
//!
//! - the `SilentDebug` and SilentDisplay macros are meant to be used on private key types, and
//! elide the... | true |
1e7ec1f84955b945839f8c302fc5801fd838305c | Rust | ZcashFoundation/zebra | /zebra-network/src/peer/connection/peer_tx.rs | UTF-8 | 1,580 | 2.90625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! The peer message sender channel.
use futures::{FutureExt, Sink, SinkExt};
use zebra_chain::serialization::SerializationError;
use crate::{constants::REQUEST_TIMEOUT, protocol::external::Message, PeerError};
/// A wrapper type for a peer connection message sender.
///
/// Used to apply a timeout to send messages... | true |
92606bfcd1cab67d92c9abe048cd7909302607ff | Rust | comit-network/cross-curve-dleq | /src/lib.rs | UTF-8 | 25,354 | 2.71875 | 3 | [] | no_license | #![allow(non_snake_case)]
mod ed25519;
mod secp256k1;
use crate::{
ed25519::{H, H_PRIME},
secp256k1::{
g,
marker::{Mark, Secret, Zero},
G, G_PRIME,
},
};
use bit_vec::BitVec;
use ecdsa_fun::{
fun::{
marker::{NonZero, Normal},
s,
},
nonce::Deterministic,
... | true |
a1bf72cbbed18b883c38e33821e69e3a94b365fc | Rust | tylermhansen/CS333 | /project7/rust_work/task1.rs | UTF-8 | 1,644 | 3.796875 | 4 | [] | no_license |
use std::fs::File;
use std::io::ErrorKind;
use std::env;
use std::mem;
use std::time::{Duration, Instant};
//allocate tons of memory when making these arrays but then they are freed as they are not used again later
fn create_stuff(){
for i in 0..2000000{
let item:[i32; 100000];
}
}
fn main(){
/... | true |
7d0844cb92ad987743da1dfb6bd9d6c17c9c908f | Rust | max-marcus/rust-book | /loops/src/main.rs | UTF-8 | 279 | 2.828125 | 3 | [] | no_license | fn main() {
let n = 8;
let mut total = 0;
let mut last = 0;
for _number in 1..n {
if total == 0 {
total = 1;
}
let last_total = total;
total = total + last;
last = last_total;
}
println!("{}", total);
}
| true |
ca4cac16092d88ebbe1aaf3b8dc47045d14053b6 | Rust | killercup/link-checker | /src/links.rs | UTF-8 | 1,998 | 2.6875 | 3 | [
"MIT"
] | permissive | use std::io::Read;
use std::collections::HashSet;
use tendril::{ByteTendril, ReadExt, StrTendril};
use html5ever::tokenizer::{TokenSink, Token, Tokenizer, TokenizerOpts};
use errors::LinkCheckerError;
#[derive(Debug)]
pub struct Links {
urls: HashSet<StrTendril>,
anchors: HashSet<StrTendril>,
ids: HashSe... | true |
c7b496d728fb734dbd335f9b31e32ad5ec8299ec | Rust | dvic/mockers | /mockers/src/box_fn.rs | UTF-8 | 4,168 | 2.75 | 3 | [
"MIT"
] | permissive | #[cfg(feature="nightly")]
mod nightly {
use std::boxed::FnBox;
pub struct BoxFn0<T>(Box<FnBox() -> T>);
impl<T> BoxFn0<T> {
pub fn new<F: 'static + FnOnce() -> T>(f: F) -> Self { BoxFn0(Box::new(f)) }
pub fn call(self) -> T { self.0() }
}
pub struct BoxFn1<A0, T>(Box<FnBox(A0) -> T... | true |
18abca221ff52284ed11385592174bac30d4cb90 | Rust | cooperra/amethyst | /src/renderer/frontend/frontend.rs | UTF-8 | 1,299 | 2.796875 | 3 | [
"MIT"
] | permissive | use super::Renderable;
use renderer::backend::Backend;
use renderer::ir::CommandQueue;
/// A collection of renderable elements to be drawn by the Frontend.
pub struct Frame {
elements: Vec<Box<Renderable>>,
}
impl Frame {
pub fn new() -> Frame {
Frame { elements: Vec::new() }
}
pub fn push<T:... | true |
220e1f3479fd9fb974ca1994157b3dfaceeaf5ef | Rust | emirayka/nia_interpreter_core | /src/interpreter/library/root/is_root_alist_has_key.rs | UTF-8 | 1,948 | 3 | 3 | [
"MIT"
] | permissive | use crate::interpreter::error::Error;
use crate::interpreter::interpreter::Interpreter;
use crate::interpreter::value::Value;
use crate::library;
pub fn is_root_alist_has_key(
interpreter: &mut Interpreter,
key: Value,
name: &str,
) -> Result<bool, Error> {
let root_alist = library::get_root_variable(... | true |
98a0d75d2c3c7a65815b41549e8073c6cde67242 | Rust | peter-bertok/brotli | /src/decoder.rs | UTF-8 | 928 | 2.9375 | 3 | [] | no_license | use bitreader::BitReader;
use std::io::{Read,Result};
static CODE_LENGTH_CODE_ORDER: [u8; 18] = [1, 2, 3, 4, 0, 5, 17, 6, 16, 7, 8, 9, 10, 11, 12, 13, 14, 15 ];
struct Decoder<BR> {
br: BR
}
impl<BR: BitReader> Read for Decoder<BR> {
fn read(&mut self, _buf: &mut [u8]) -> Result<usize> {
unimplemente... | true |
d055afe3f12d214da90d3c4d5429e50fe5a05089 | Rust | rse-standrewscs/shallow-water | /src/spectral/test.rs | UTF-8 | 16,550 | 2.578125 | 3 | [] | no_license | use {
super::*,
crate::{array2_from_file, array3_from_file, utils::*},
approx::assert_abs_diff_eq,
byteorder::{ByteOrder, NetworkEndian},
ndarray::ShapeBuilder,
};
macro_rules! _1d_from_file {
($name:expr) => {
include_bytes!($name)
.chunks(8)
.map(NetworkEndian:... | true |
70363cff701696fde8752ca781878efd5c8c1df5 | Rust | m-ou-se/klondike | /src/foundation.rs | UTF-8 | 2,171 | 3.28125 | 3 | [] | no_license | use intbits::Bits;
use crate::*;
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct Foundation {
state: u16,
}
impl Foundation {
pub const fn new() -> Self {
Self { state: 0 }
}
pub const fn is_complete(&self) -> bool {
self.state == 0xDDDD
}
pub fn add(&mut self, card: Card) -> Result<(), ()> {
if card.r... | true |
b4c6e1c22eb42551d381aab0cd184fef983fdf56 | Rust | projectfluent/fluent-rs | /fluent-pseudo/src/lib.rs | UTF-8 | 4,494 | 2.65625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use regex::Captures;
use regex::Regex;
use std::borrow::Cow;
static TRANSFORM_SMALL_MAP: &[char] = &[
'a', 'ƀ', 'ƈ', 'ḓ', 'e', 'ƒ', 'ɠ', 'ħ', 'i', 'ĵ', 'ķ', 'ŀ', 'ḿ', 'ƞ', 'o', 'ƥ', 'ɋ', 'ř', 'ş',
'ŧ', 'u', 'ṽ', 'ẇ', 'ẋ', 'ẏ', 'ẑ',
];
static TRANSFORM_CAPS_MAP: &[char] = &[
'A', 'Ɓ', 'Ƈ', 'Ḓ', 'E', 'Ƒ', 'Ɠ... | true |
9d3d62af5d98b2680a3fe9dc5138937f3f0dd0cb | Rust | acmcarther/cargo-raze-examples | /bazel/complicated_cargo_library/cargo/vendor/crossbeam-0.3.2/src/scoped.rs | UTF-8 | 9,368 | 3.375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::cell::RefCell;
use std::fmt;
use std::mem;
use std::rc::Rc;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::thread;
use std::io;
use {builder_spawn_unsafe, FnBox};
use sync::AtomicOption;
pub struct Scope<'a> {
dtors: RefCell<Option<DtorChain<'a>>>
}
struct DtorChain<'a> {
dtor: Box<Fn... | true |
4107b94acbe8bc08971ab98c7027af2b9042f38a | Rust | sonygod/rust-project-euler | /euler79/src/main.rs | UTF-8 | 760 | 2.640625 | 3 | [] | no_license | fn main() {
let data = std::fs::read_to_string("keylog.txt").expect("打开文件失败");
let data2 = data.trim().replace("\r", "");
let lines = data2.split("\n");
let mut set: Vec<(&str, &str)> = vec![];
for line in lines {
let a = &line[..1];
let b = &line[1..=1];
let c = &line[2..];... | true |
027ce21d64e5407985b8520b1d415b42858a8533 | Rust | rbalicki2/wasm-experiments | /src/lib.rs | UTF-8 | 796 | 2.65625 | 3 | [] | no_license | #![feature(libc)]
extern crate libc;
use std::os::raw::c_char;
// use std::ffi::CStr;
use std::ffi::CString;
// use std::os::raw::c_void;
// use std::mem;
mod externs;
// #[macro_use]
// extern crate stdweb;
#[no_mangle]
pub fn get_str() -> *mut c_char {
let s = CString::new("ASDF").unwrap();
s.into_raw()
}
#[n... | true |
f02cffa38af16d9cd61b2a87d7739c1a545c431d | Rust | vova616/htm | /src/util/peekable_while.rs | UTF-8 | 1,694 | 3.4375 | 3 | [] | no_license | use std::iter;
pub struct PeekableWhile<'a, I : Iterator + 'a, P: FnMut(&I::Item) -> bool> {
iter: &'a mut iter::Peekable<I>,
predicate: P,
}
pub trait PeekableWhileTrait<'a, I : Iterator,P: FnMut(&I::Item) -> bool> {
fn take_while_peek(&'a mut self, predicate:P) -> PeekableWhile<'a, I,P>;
}
impl<'a, I:... | true |
3b1f8fc00d3b6ba7030cc943a502925e659bebfe | Rust | MaxOhn/Bathbot | /bathbot-macros/src/prefix/options.rs | UTF-8 | 2,805 | 2.71875 | 3 | [
"ISC"
] | permissive | use proc_macro2::Span;
use syn::{
punctuated::Punctuated, spanned::Spanned, token::Comma, Attribute, Error, Ident, LitStr, Meta,
MetaList, Result as SynResult, Result,
};
use crate::{
bucket::{parse_bucket, Bucket},
flags::{parse_flags, Flags},
util::AsOption,
};
pub struct Options {
pub alias... | true |
cafd4da15c4d89118c5bd5e8367c43cc877caa78 | Rust | alexandervoronov/pokemon-in-shakespeare | /src/main.rs | UTF-8 | 22,795 | 2.59375 | 3 | [
"MIT"
] | permissive | extern crate bytes;
extern crate chashmap;
extern crate futures;
extern crate reqwest;
extern crate serde;
extern crate serde_json;
extern crate tokio;
extern crate url;
extern crate warp;
type Result<T> = std::result::Result<T, RequestError>;
#[tokio::main]
async fn main() {
println!("");
println!("Pokémons ... | true |
76ba94c4124d949982c38aa49e438efdc6fc6c4b | Rust | EFanZh/LeetCode | /src/problem_0879_profitable_schemes/dynamic_programming.rs | UTF-8 | 1,787 | 2.640625 | 3 | [] | no_license | pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
impl Solution {
pub fn profitable_schemes(n: i32, min_profit: i32, group: Vec<i32>, profit: Vec<i32>) -> i32 {
const MODULUS: u32 = 1_000_000_007;
let n = ... | true |
05e7bf6abcd7a8fc0d9b0e698e19cc755e54973e | Rust | sdroege/gtk-subclass | /gtk-examples/src/cell_renderer_example.rs | UTF-8 | 4,493 | 2.921875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! # Custom Cell Renderer Sample
//!
//! This sample demonstrates how to create a gtk::CellRenderer subclass
extern crate gdk;
extern crate gio;
extern crate gtk;
#[macro_use]
extern crate glib;
extern crate cairo;
extern crate pango;
extern crate glib_sys as glib_ffi;
extern crate gobject_sys as gobject_ffi;
extern... | true |
523258be92448a1c6dad5a9f275ccae314dfbd76 | Rust | jotaszewsky/mycelium | /src/plugins/amqp.rs | UTF-8 | 8,032 | 2.71875 | 3 | [
"MIT"
] | permissive | extern crate amiquip;
use self::amiquip::{AmqpValue, Connection, Channel, ConsumerMessage, ConsumerOptions, QueueDeclareOptions, Result, FieldTable, Exchange, Publish, AmqpProperties};
extern crate serde;
extern crate serde_json;
use std::collections::{HashMap, BTreeMap};
use application::event_source::EventSource;
u... | true |
e640731c3bb6b187096773c93281510f70197941 | Rust | ultrasilicon/surt | /src/materials.rs | UTF-8 | 2,747 | 3.203125 | 3 | [] | no_license | use crate::color::ColorRGB;
use crate::ray::Ray;
use crate::surface::HitRecord;
use crate::vector::Vector3d;
use rand::Rng;
#[derive(Copy, Clone)]
pub enum Material {
Lambertian { albedo: ColorRGB },
Metal { albedo: ColorRGB, fuzz: f64 },
Dielectric { ir: f64 },
}
pub fn refract(uv: Vector3d, n: Vector... | true |
2ad4ad2803c966620fe3337219a4bdbd14224d1f | Rust | dmgolembiowski/RustyKitchen | /structures/main.rs | UTF-8 | 2,471 | 3.96875 | 4 | [] | no_license | /*
* The are three types of `structs` in Rust, which
* can be created using the ```struct``` keyword:
* - Tuple structs, which are NamedTuples
* - The classic C structs
* - Unit structs, which are fieldless, and are useful for generics
*/
// NamedTuple-y One
#[derive(Debug)]
struct Person<'a> {
name: &'a... | true |
6f0685b584b11266b1a5371a28c5099812e81ce2 | Rust | Time0o/rust-cpp | /src/main.rs | UTF-8 | 163 | 2.703125 | 3 | [] | no_license | mod integer_rust;
fn main() {
println!("WTF");
let mut i = integer_rust::Integer::new(1);
println!("{}", i.get());
i.set(2);
println!("{}", i.get());
}
| true |
9086a6cf40fb3fc97b7df70f3851d43ba18debcd | Rust | PhilipDaniels/qork | /src/rust/qork/src/program_info.rs | UTF-8 | 3,449 | 2.84375 | 3 | [
"MIT"
] | permissive | use std;
use std::fmt;
use std::fs::Metadata;
use std::path::PathBuf;
use std::time::SystemTime;
use libc;
use libc::{pid_t};
use users;
use users::{uid_t, gid_t};
use command_line_arguments::CommandLineArguments;
use datetime::{format_system_time_as_utc};
/// Information about the program we are running (qork.exe),... | true |
80abdefa5af46944d9b5e079cad07bf128970965 | Rust | vakabus/rumipsem | /src/cpu/control.rs | UTF-8 | 9,234 | 2.890625 | 3 | [] | no_license | //! CPU control logic. Orchestrates all components together to simulate the CPU.
use cpu::event::CPUEvent;
use cpu::instructions::eval_instruction;
use cpu::registers::RegisterFile;
use cpu::watchdog::Watchdog;
use memory::Memory;
use std::collections::VecDeque;
use std::io;
use std::io::Read;
use syscalls::System;
#... | true |
52383222515a4fda6d7366d95ee11dc44ddd205d | Rust | killercup/rune | /crates/rune-testing/examples/object.rs | UTF-8 | 472 | 3 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use rune_testing::{run, Result};
use runestick::{Object, Value};
fn main() -> Result<()> {
let mut object = Object::new();
object.insert(String::from("Hello"), Value::from(42i64));
let object: Object = run(
&["calc"],
(object,),
r#"
fn calc(input) {
dbg(input["H... | true |
4d365fb243aaafb227ed5b20c522b287c43578e4 | Rust | cosmo0920/ruroonga_command | /src/dsl/logical_table_remove_dsl.rs | UTF-8 | 658 | 2.90625 | 3 | [
"MIT"
] | permissive | use logical_table_remove::LogicalTableRemoveCommand;
pub fn logical_table_remove(logical_table: String, shard_key: String) -> LogicalTableRemoveCommand {
LogicalTableRemoveCommand::new(logical_table, shard_key)
}
#[cfg(test)]
mod test {
use super::*;
use logical_table_remove::LogicalTableRemoveCommand;
... | true |
ca4b8c95e4693513f2c1d1fcf05b3cd1e2a064bd | Rust | nasa8x/ckb | /shared/src/tx_proposal_table.rs | UTF-8 | 3,894 | 2.890625 | 3 | [
"MIT"
] | permissive | use ckb_chain_spec::consensus::ProposalWindow;
use ckb_core::header::BlockNumber;
use ckb_core::transaction::ProposalShortId;
use ckb_logger::trace_target;
use ckb_util::FnvHashSet;
use std::collections::BTreeMap;
use std::ops::Bound;
#[derive(Debug, PartialEq, Clone, Eq)]
pub struct TxProposalTable {
pub(crate) t... | true |
f8e97644b71efaee72664f25fa4ec12942d729a0 | Rust | fhartwig/gearbox | /src/tracker.rs | UTF-8 | 8,995 | 2.640625 | 3 | [] | no_license | use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian};
use url::{Url, form_urlencoded};
use url::percent_encoding::{percent_encode, QUERY_ENCODE_SET};
use hyper::client::request::Request;
use hyper::method::Method;
use rand::random;
use bencode::{BValue, FromBValue, ConversionResult};
use bencode::ConversionError::O... | true |
e07e9bdf792067a9c014ba3a9edeaa5603913af5 | Rust | sdbondi/bn-api | /api/src/payments/stripe/mod.rs | UTF-8 | 3,626 | 2.609375 | 3 | [
"BSD-3-Clause"
] | permissive | use payments::charge_auth_result::ChargeAuthResult;
use payments::charge_result::ChargeResult;
use payments::payment_processor::AuthThenCompletePaymentBehavior;
use payments::payment_processor::PaymentProcessor;
use payments::payment_processor::PaymentProcessorBehavior;
use payments::payment_processor_error::PaymentPro... | true |
d1133e10cce7ad33a3646fab087468c77ba93cfa | Rust | n3phtys/typescriptify | /typescriptify-derive/src/lib.rs | UTF-8 | 15,611 | 2.734375 | 3 | [] | no_license | extern crate proc_macro;
extern crate syn;
#[macro_use]
extern crate quote;
use proc_macro::TokenStream;
#[proc_macro_derive(TypeScriptify)]
pub fn hello_world(input: TokenStream) -> TokenStream {
// Construct a string representation of the type definition
let s = input.to_string();
// Parse the string r... | true |
a50a7ef40adf2f7b9004ff6262c18fb891035950 | Rust | jkristell/stm32f4xx-hal | /src/i2c.rs | UTF-8 | 13,909 | 2.609375 | 3 | [
"0BSD",
"BSD-3-Clause"
] | permissive | use core::ops::Deref;
use crate::pac::{self, i2c1};
use crate::rcc::{Enable, Reset};
use crate::gpio::{Const, OpenDrain, PinA, SetAlternate};
use crate::pac::RCC;
use crate::rcc::Clocks;
use fugit::{HertzU32 as Hertz, RateExtU32};
mod hal_02;
mod hal_1;
#[derive(Debug, Eq, PartialEq)]
pub enum DutyCycle {
Rati... | true |
b76198d4de2b9a329ab32c3d5ab564a9bcb5054a | Rust | noeddl/rustfst | /rustfst/src/algorithms/cache/cache_impl.rs | UTF-8 | 2,941 | 2.828125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::slice::Iter as IterSlice;
use failure::Fallible;
use crate::algorithms::cache::VectorCacheState;
use crate::semirings::Semiring;
use crate::Arc;
use crate::StateId;
pub struct CacheImpl<W: Semiring> {
has_start: bool,
cache_start_state: Option<StateId>,
vector_cache_states: VectorCacheState<W>,
... | true |
a19ec816049d14162758379bfe8b555e2a907681 | Rust | VennilaPugazhenthi/rust_programming | /variables/src/main.rs | UTF-8 | 111 | 3.34375 | 3 | [] | no_license | fn main() {
let x=5;
let x =x+1;
let x= x*2;
println!("The value of x is: {}",x);
}
| true |
e7fd34d3122142700513c823821a57f08af0bb36 | Rust | swkfn/cli_tool | /src/main.rs | UTF-8 | 1,290 | 2.9375 | 3 | [] | no_license | extern crate cli_tool; // 外部クレートはsrcに構成する
extern crate failure;
#[macro_use]
extern crate clap;
use std::io::prelude::*;
use std::collections::HashMap;
// use std::env;
use std::fs::File;
use clap::{Arg};
fn parse_command(){
let app = app_from_crate!()
.arg(Arg::from_usage("<TEXT> 'ファイルを指定してください.'"));... | true |
37bae788f4fb0ee5e5692a001a7f1cf867a6c00b | Rust | boxdot/osmflat-rs | /osmflatc/src/strings.rs | UTF-8 | 5,939 | 3.1875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LGPL-3.0-only"
] | permissive | use ahash::AHashMap;
#[derive(Debug, Clone, Copy)]
struct TerminatedStringPtr {
ptr: *const u8,
}
// We use this (unsafe) wrapper to get the most compact hashmap possible
// Using a "&'static str" would be bigger due to the length stored
// Using a String would allocate a lot of individual blocks
// Using a small... | true |
9c1c277bdf36578eadb0cafb8bd329ea3b1821d2 | Rust | Shemnei/carob | /crates/carob-lang/src/span.rs | UTF-8 | 3,680 | 3.03125 | 3 | [
"Unlicense"
] | permissive | use std::ops::Range;
use crate::pos::{BytePos, Pos as _};
pub type OffsetWidth = i32;
pub trait Span {
type Pos: crate::pos::Pos;
type IdxOutput: ?Sized;
fn with_low(&self, low: Self::Pos) -> Self;
fn with_high(&self, high: Self::Pos) -> Self;
fn offset_low(&self, offset: OffsetWidth) -> Self;
fn offset_high... | true |
0e55f5299b4ad26ec44785788387172ce8241837 | Rust | tetigi/rs-transducers | /src/applications.rs | UTF-8 | 8,122 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | /*
* Copyright 2016 rs-transducers developers
*
* Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
* http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
* <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
* option. This file may not be copied, modified, or distributed
* exc... | true |
2706cf3b1f38f95649337a4f3fdc65b410db2b08 | Rust | zhongwei/rustnote | /rustbyexample/016/iterators.rs | UTF-8 | 1,167 | 4.21875 | 4 | [
"MIT"
] | permissive | struct Fibonacci {
curr: u32,
next: u32,
}
impl Iterator for Fibonacci {
type Item = u32;
fn next(&mut self) -> Option<u32> {
let new_next = self.curr + self.next;
self.curr = self.next;
self.next = new_next;
Some(self.curr)
}
}
fn fibonacci() -> Fibonacci {
... | true |
0afd5a3fb5050947f7ab1e819cb21bd179a03f80 | Rust | ffwff/iro | /tests/compiler/typing.rs | UTF-8 | 2,015 | 2.59375 | 3 | [
"MIT"
] | permissive | use crate::utils;
use iro::runtime::Runtime;
use std::sync::atomic::{AtomicBool, Ordering};
#[cfg(test)]
#[test]
fn cast_on_argument() {
static RUN_FLAG: AtomicBool = AtomicBool::new(false);
extern "C" fn record_i64(n: i64) {
assert_eq!(n, 10);
RUN_FLAG.store(true, Ordering::Relaxed);
}
... | true |
10e9865aaa19707ee7ae70fb50c5ce72675893b8 | Rust | Proximyst/AOC2019 | /src/day4.rs | UTF-8 | 3,684 | 3.5625 | 4 | [] | no_license | use crate::DigitAtPosition as _;
use rayon::prelude::*;
#[aoc_generator(day4)]
pub fn gen(range: &str) -> (u32, u32) {
let split = range
.split('-')
.flat_map(str::parse)
.collect::<Vec<_>>();
assert_eq!(split.len(), 2);
(split[0], split[1])
}
#[aoc(day4, part1)]
pub fn part1_impl... | true |
7b9cf911af43debea723ede437b5a6de904bc1ce | Rust | MindFlavor/azure-sdk-for-rust | /sdk/storage/src/table/continuation_next_partition_and_row_key.rs | UTF-8 | 1,474 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-generic-cla",
"LGPL-2.1-or-later"
] | permissive | use azure_core::AppendToUrlQuery;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ContinuationNextPartitionAndRowKey(String, Option<String>);
impl ContinuationNextPartitionAndRowKey {
pub fn new(
continuation_next_partition_key: String,
continuation_next_row_key: Option<Strin... | true |
dc0042aa1b1ed6a3dc1c1a3423a6b71e4021a54e | Rust | bschwind/yoga-rs | /src/ffi_types/align.rs | UTF-8 | 1,655 | 2.84375 | 3 | [
"MIT"
] | permissive | use crate::internal;
#[repr(u32)]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Clone)]
#[cfg_attr(feature = "serde_support", derive(Serialize, Deserialize))]
pub enum Align {
Auto = 0,
FlexStart = 1,
Center = 2,
FlexEnd = 3,
Stretch = 4,
Baseline = 5,
SpaceBetween = 6,
Sp... | true |
ceefb5376e945d91fc58490e7f288024019f74f7 | Rust | mneumann/rust-smtp | /src/parser.rs | UTF-8 | 5,198 | 3.15625 | 3 | [
"BSD-2-Clause",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[feature(macro_rules)];
use std::result::{Result,Ok,Err};
#[deriving(Eq,Show)]
enum SmtpCommand<'a> {
MAIL(&'a str),
RCPT(&'a str),
DATA,
}
#[deriving(Eq,Show)]
enum ParseError {
SyntaxError(&'static str),
InvalidLineEnding,
UnknownCommand,
}
fn ascii_eq_ignore_case(a: &[u8], b: &[u8]) -> bool {
if a... | true |
9d197cbd2fb1a13afe09f9e8705a30c3fce0d1c4 | Rust | daboross/rust-throw | /tests/std_tests.rs | UTF-8 | 1,328 | 3.171875 | 3 | [
"MIT"
] | permissive | #![cfg(feature = "std")]
#[macro_use]
extern crate throw;
use throw::Result;
#[derive(Debug)]
struct CustomError(String);
impl std::fmt::Display for CustomError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "CustomError: {}", self.0)
}
}
impl std::error::Error for Cust... | true |
c9fcc18595535f554957620562f1764d3bdeece8 | Rust | complez-rs/approximate_seq | /src/tests.rs | UTF-8 | 2,654 | 2.890625 | 3 | [] | no_license | use crate::funcseq::*;
use crate::seq::*;
use num_complex::Complex;
use num_traits::Zero;
use rand::prelude::*;
const ARR_SIZE: usize = 8;
const STEP: usize = 10000;
const TESTCASES: usize = 100;
const S0: f64 = 0.0;
const R0: f64 = 1.0;
const DELTA: f64 = 0.3;
#[test]
fn log_approx_test() {
let mut rng = thread_... | true |
b00ec0669bb5b33f7be9b9343989c2845b21d82b | Rust | juga999/AoC | /2020/day3/src/main.rs | UTF-8 | 1,283 | 3.28125 | 3 | [] | no_license | use std::fs;
use array2d::Array2D;
fn count_trees(pattern: &Array2D<char>, slope: &(usize, usize)) -> usize {
let mut tree_count = 0;
let mut pos = (0,0);
while pos.0 < pattern.num_rows() {
if pattern.get(pos.0, pos.1 % pattern.num_columns()) == Some(&'#') {
tree_count += 1;
}
... | true |
8d508d48abc38f4c2c25173f7ee3a0df4e40b492 | Rust | simnalamburt/snippets | /rust/default-type.rs | UTF-8 | 201 | 2.890625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::mem::zeroed;
#[derive(Debug)]
struct Data<T = i32> { data: T }
fn new<T>() -> Data<T> { Data { data: unsafe { zeroed() } } }
fn main() {
let a: Data = new();
println!("{:?}", a);
}
| true |
ed6549747eab552f99a14a692d3f49b8711bb09d | Rust | jarry-xiao/rust-graph-algos | /src/priority_queue.rs | UTF-8 | 1,916 | 3.640625 | 4 | [] | no_license | use std::fmt::Debug;
pub struct PriorityQueue<T> {
data: Vec<T>,
size: usize,
maxsize: Option<usize>,
}
pub fn build_priority_queue<T>(data: Option<Vec<T>>, maxsize: Option<usize>) -> PriorityQueue<T> {
match data {
Some(x) =>
return PriorityQueue{
data: x,
... | true |
4b2716d042a67591c7fa33460e278e1d038339c3 | Rust | KlasafGeijerstam/Kattis | /rust/tgif.rs | UTF-8 | 1,541 | 3.0625 | 3 | [] | no_license | mod inp;
use inp::Inp;
use std::collections::HashSet;
fn main() {
let mut inp = Inp::new();
let (today, month) = {
let mut l = inp.next_line().trim().split(' ');
(l.next().unwrap().parse::<u16>().unwrap(),
match l.next().unwrap() {
"JAN" => 0,
"FE... | true |
facf7d3e67619a8507c61003147de2c39691bbce | Rust | SplittyDev/zircond | /src/message/tag.rs | UTF-8 | 578 | 3.109375 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | pub struct IrcMessageTag(pub String, pub Option<String>);
impl ToString for IrcMessageTag {
fn to_string(&self) -> String {
// Pre-calculate the exact tag size
let len = self.0.len() + self.1.as_ref().map_or(0, |tag| tag.len() + 1);
// Allocate a perfectly fitted string
let mut bu... | true |
dce2cd58155709aad6e89258c50c3d2f5e10f16f | Rust | yamash723/til | /atcoder/ABC/abc-251c-poem-online-judge/src/main.rs | UTF-8 | 658 | 2.625 | 3 | [
"MIT"
] | permissive | // -*- coding:utf-8-unix -*-
use std::collections::HashSet;
use proconio::input;
fn main() {
input! {
n: usize,
submissions: [(String, usize);n],
}
let n: usize = n;
let submissions: Vec<(String, usize)> = submissions;
let mut map = HashSet::new();
let (mut res_i, mut max_po... | true |
7d0611f90c172cff45c304754684f6fb4b27a811 | Rust | mattr555/advent-of-code | /2016/src/days/day07.rs | UTF-8 | 1,636 | 3.15625 | 3 | [] | no_license | use std::collections::HashSet;
use std::error::Error;
fn has_abba(input: &str) -> bool {
let s: &[u8] = input.as_bytes();
let mut is_outside = true;
let mut found_outside = false;
let mut found_inside = false;
for i in 0..(s.len() - 3) {
if s[i] == '[' as u8 {
is_outside = false... | true |
7e3fcc926d94caa09d82bceb04617a8eb2d9d1a1 | Rust | lucab/serde_gvariant | /examples/ostree-dirtree.rs | UTF-8 | 1,712 | 2.609375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | extern crate env_logger;
extern crate log;
#[macro_use]
extern crate serde_derive;
extern crate serde_gvariant;
use serde_gvariant::errors;
use std::{fs, io};
/// An ostree dirtree object.
///
/// Signature: "(a(say)a(sayay))"
/// Original definition at:
/// https://github.com/ostreedev/ostree/blob/v2018.5/src/libost... | true |
0b09db6f01d96ffdfcdd722efb4959a678ddd745 | Rust | strogo/qt.gen | /src/demo.rs | UTF-8 | 593 | 3.734375 | 4 | [] | no_license | pub struct Foo {
value:uint
}
trait HasUIntValue {
fn as_uint(self) -> uint;
}
pub impl Foo {
fn add<T:HasUIntValue>(&mut self, value:T) {
self.value += value.as_uint();
}
}
impl HasUIntValue for int {
fn as_uint(self) -> uint {
return self as uint;
}
}
impl HasUIntValue for (f64) {
fn as_uint... | true |
50c12672d1d1fae0ad28e48cd473b0c94cb1428e | Rust | azriel91/autexousious | /crate/application/src/app_dir.rs | UTF-8 | 3,240 | 3.015625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Constants for resource directories.
use std::{
io,
marker::PhantomData,
path::{Path, PathBuf},
};
use amethyst::{utils::application_root_dir, Error};
use crate::AppFile;
#[cfg(not(target_arch = "wasm32"))]
use crate::DiscoveryContext;
/// Functions to discover and interact with application files.
#[... | true |
dd1e5d95198df152217137319d6a7f6f36317640 | Rust | parkerziegler/rust-book | /iterators/src/main.rs | UTF-8 | 1,823 | 4.28125 | 4 | [] | no_license | fn main() {
let v = vec![1, 2, 3];
// We can create iterators from different data structures
// that implement the Iterator trait.
for entry in v.iter() {
println!("{}", entry);
}
}
#[test]
fn it_iterates() {
let v = vec![1, 2, 3];
// Here we make the iterator mutable, because call... | true |
83286dcc92c37c98c6c794b37c0c68e9e462cf32 | Rust | ultracold273/leetcode-rs | /src/code_contest/pr1.rs | UTF-8 | 181 | 3.140625 | 3 | [] | no_license |
fn min_count(coins: Vec<i32>) -> i32 {
let mut count = Vec::new();
for coin in coins {
let c = (coin + 1) / 2;
count.push(c);
}
count.iter().sum()
} | true |
7422bb4182f40387f698259b949b0121980b58f6 | Rust | WeikangChen/kattis | /addingwords/add.rs | UTF-8 | 2,181 | 3.375 | 3 | [] | no_license | use std::io::{self, BufRead};
// use std::ops::{Add, Sub};
use std::collections::HashMap;
struct Words {
var2num: HashMap<String, i32>,
num2var: HashMap<i32, String>,
}
impl Words {
fn def(&mut self, strs: &[&str]) {
let var = String::from(strs[0]);
let num: i32 = strs[1].parse().unwrap();... | true |
95d05ab53701ccf4b72de794067b62e6cfd88ff7 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/futures-macro/src/select.rs | UTF-8 | 9,383 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | /
/
!
The
futures
-
rs
select
!
macro
implementation
.
use
proc_macro
:
:
TokenStream
;
use
proc_macro2
:
:
Span
;
use
quote
:
:
{
format_ident
quote
}
;
use
syn
:
:
parse
:
:
{
Parse
ParseStream
}
;
use
syn
:
:
{
parse_quote
Expr
Ident
Pat
Token
}
;
mod
kw
{
syn
:
:
custom_keyword
!
(
complete
)
;
}
struct
Select
{
/
... | true |
bc842fd105b9c83a3957d91861c09a74a9595026 | Rust | Gawaboumga/rustracer | /src/raytracer/sphere.rs | UTF-8 | 2,806 | 3.28125 | 3 | [] | no_license | use super::color::Color;
use super::geometry::Geometry;
use super::geometry::HitInfo;
use super::ray::Ray;
use super::vec3::Vec3;
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Sphere {
center: Vec3,
color: Color,
radius: f32,
reflection_factor: Option<f32>,
transparency_factor: Option<f32>,
}... | true |
903cda70b81014d50f4bb1217821c881f3952b6f | Rust | litchipi/Petridish | /src/genalgomethods.rs | UTF-8 | 2,790 | 2.59375 | 3 | [
"MIT"
] | permissive | use crate::cell::{Cell, CellData, Genome};
use crate::errors::Errcode;
use crate::utils::JsonData;
use serde::{Deserialize, Serialize};
use strum_macros::{EnumIter, EnumString};
mod random_opti;
mod darwin_method;
//TODO IMPORTANT Create genome mutation method trait and child creation trait
// Use en... | true |
7f040cca24cf3679f7fa274ce0f8bcc72b19718f | Rust | zhenfeizhang/poly_mul | /src/test/poly_z.rs | UTF-8 | 1,157 | 2.765625 | 3 | [] | no_license | use poly_z::*;
use std::ops::*;
//
// #[test]
// fn test_poly_z_add() {
// let a = Poly::<u64> {
// degree: 4,
// coeff: vec![1, 2, 3, 4],
// };
// let b = a.clone();
// let c = a + b;
// assert_eq!(
// c,
// Poly::<u64> {
// degree: 4,
// coef... | true |
65801f2e216524a14d73f2899d8ae73dea1f4926 | Rust | wikrsh/raytracing_in_one_weekend_rust | /src/camera.rs | UTF-8 | 1,554 | 3.109375 | 3 | [
"MIT"
] | permissive | use crate::geometry::Ray;
use crate::utils::vec3::Vec3;
pub struct Camera {
origin: Vec3,
lower_left_corner: Vec3,
horizontal: Vec3,
vertical: Vec3,
u: Vec3,
v: Vec3,
lens_radius: f64,
}
impl Camera {
pub fn new(
lookfrom: Vec3,
lookat: Vec3,
vup: Vec3,
... | true |
8fcad4458ea9a53b4959216e94f299301ebaea03 | Rust | CJTozer/rust_play | /src/main.rs | UTF-8 | 2,194 | 3.21875 | 3 | [] | no_license | /// Test of some pluggable architecutures in Rust
use std::sync::mpsc::{Sender, Receiver};
use std::sync::mpsc;
extern crate timer;
extern crate chrono;
// Main thread spawns a set of WatchHandler objects
// Each one of these has one watcher to look after
// Watcher is started, given a channel to send regular heartbe... | true |
410bf9e37ceb2e72ef7fe2192a0d79308a684bca | Rust | mdaverde/fnq | /src/ops/wait.rs | UTF-8 | 725 | 2.5625 | 3 | [
"MIT"
] | permissive | use std::path;
use crate::ops::{block_on_locked_file, files, OpsError};
pub fn block(queue_dir: path::PathBuf, queue_file: Option<path::PathBuf>) -> Result<(), OpsError> {
let queue_files = files::files(&queue_dir)?;
if let Some(queue_file) = queue_file {
match queue_files
.iter()
... | true |
8fc36dc7ab07e076ecbde95195b38fa5b8ccb041 | Rust | watashi/AlgoSolution | /codeforces/ac/16/1612/B.rs | UTF-8 | 1,107 | 2.765625 | 3 | [] | no_license | use std::*;
fn read_line() -> String {
let mut line = String::new();
io::stdin().read_line(&mut line).unwrap();
line
}
fn read_vec<T: str::FromStr>() -> Vec<T> {
read_line()
.split_whitespace()
.filter_map(|i| i.parse().ok())
.collect()
}
fn join<T>(a: impl IntoIterator<Item =... | true |
f80ecd535a30c099bb0c2749c5fd9d0aa311a89e | Rust | mystor/aumc | /src/main.rs | UTF-8 | 3,324 | 2.78125 | 3 | [] | no_license | extern crate docopt;
extern crate rustc_serialize;
use std::io::prelude::*;
use std::fs::File;
use std::path::PathBuf;
use docopt::Docopt;
#[macro_use]
mod err;
mod common;
mod ast;
mod lex;
mod parse;
mod prgm;
mod arena;
// Docopt usage for the program
static USAGE: &'static str = "
Usage: aumc [options] <INPUT>
... | true |
3440ad6518595db2ef264d77d7e1c280b6dad48e | Rust | sccommunity/crates-sgx | /crates/serde/sgx-tests/enclave/src/expand/generic_struct.expanded.rs | UTF-8 | 24,276 | 2.5625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use serde::{Deserialize, Serialize};
pub struct GenericStruct<T> {
x: T,
}
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const _IMPL_SERIALIZE_FOR_GenericStruct: () = {
#[allow(unknown_lints)]
#[allow(rust_2018_idioms)]
extern crate serde as _serde;
#[automatically_deriv... | true |
58ba5b9da9d99461150c1b78a5cdceaa01c632ae | Rust | Xannden/aoc2020 | /src/days/day18.rs | UTF-8 | 2,642 | 3.40625 | 3 | [] | no_license | use logos::{Lexer, Logos};
use std::{collections::HashMap, fs::File, io::Read, iter::Peekable};
pub fn run() {
let mut file = File::open("input/day18.txt").unwrap();
let mut data = String::new();
file.read_to_string(&mut data).unwrap();
part1(&data);
part2(&data);
}
#[derive(Logos, Debug, Clone,... | true |
b5b54a46f73ddeca5ed233d0c312dff7c3605c65 | Rust | manaskarekar/convrs | /src/ir.rs | UTF-8 | 1,619 | 2.890625 | 3 | [] | no_license | #![allow(non_snake_case)]
use std::fs::File;
use std::io::{Read, Write};
//use std::path::Path;
//use std::error::Error;
/*
#[derive(RustcDecodable, RustcEncodable, Debug)]
pub struct IRAttribute {
color: String,
bgcolor: String,
style: String, //example: "biu" -> bold and italic and underscored if supported.
}
*/... | true |
9c926ad9a0faf12b3ab3344620117fae88203dd5 | Rust | qwerty2501/experimental-wasm-aot | /src/error.rs | UTF-8 | 3,655 | 2.6875 | 3 | [
"MIT"
] | permissive |
use failure::Error;
use num::*;
use parity_wasm::elements::Instruction;
#[derive(Debug,Fail)]
pub enum RuntimeError{
#[fail(display = "error occurred : {}",name)]
Application{
name:String,
},
#[fail(display = "no such llvm function : {}",name)]
NoSuchLLVMFunction {
name:String,
... | true |
e8446b89d9fab14ab2c5e1269f20f17cc7564a4e | Rust | utilForever/BOJ | /Rust/25639 - Sequence and Maximum Rise Query.rs | UTF-8 | 3,270 | 3.171875 | 3 | [
"MIT"
] | permissive | use io::Write;
use std::{io, str};
pub struct UnsafeScanner<R> {
reader: R,
buf_str: Vec<u8>,
buf_iter: str::SplitAsciiWhitespace<'static>,
}
impl<R: io::BufRead> UnsafeScanner<R> {
pub fn new(reader: R) -> Self {
Self {
reader,
buf_str: vec![],
buf_iter: ""... | true |
ac5ed7b0fd6a17c29b73c15ac34188613efc64fd | Rust | geokala/korama | /src/track.rs | UTF-8 | 3,566 | 3.5625 | 4 | [] | no_license | use std::cmp::Ordering;
use crate::delimiters::{END_OF_FIELD, END_OF_RECORD};
#[derive(Clone)]
pub struct Track {
pub track_name: String,
pub artist: String,
pub album: String,
pub track_number: String, // Yes, a string, because of hidden tracks on some albums
pub path: String,
}
impl Track {
... | true |
bf26c45e4b5ed13991b87baf3ab07a51b4e8f335 | Rust | mrmicahcooper/cook | /code/build-app/src/main.rs | UTF-8 | 1,279 | 3.171875 | 3 | [] | no_license | extern crate handlebars;
extern crate serde_json;
extern crate serde;
extern crate glob;
extern crate regex;
use glob::glob;
use regex::Regex;
use handlebars::Handlebars;
use serde::{Serialize};
use std::vec::{Vec};
use std::fs::read_to_string as read_file;
use std::fs::write as write_file;
#[derive(Serialize)]
struc... | true |
7f10f4fa9cff2ab2bd13b9c9346f71520109186e | Rust | Logicalshift/flo_curves | /tests/bezier/path/arithmetic_cut.rs | UTF-8 | 3,432 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | use flo_curves::*;
use flo_curves::bezier::path::*;
#[test]
fn cut_square() {
let square_1 = BezierPathBuilder::<SimpleBezierPath>::start(Coord2(5.0, 5.0))
.line_to(Coord2(10.0, 5.0))
.line_to(Coord2(10.0, 10.0))
.line_to(Coord2(5.0, 10.0))
.line_to(Coord2(5.0, 5.0))
.bui... | true |
b25ac088dd138ffc940c63ab7b04c92f559a8e7c | Rust | oliver-giersch/conquer-reclaim | /src/retired.rs | UTF-8 | 2,527 | 2.796875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use core::cmp;
use core::fmt;
use core::ptr::NonNull;
use crate::traits::ReclaimBase;
// *************************************************************************************************
// Retired
// *************************************************************************************************
pub struct Retired... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.