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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
378e53001f470a2ab4056799ec347256081ba050 | Rust | tlinford/raytracer-challenge-rs | /raytracer/src/geometry/shape/test_shape.rs | UTF-8 | 4,102 | 3.3125 | 3 | [] | no_license | use std::{any::Any, sync::RwLock};
use crate::{
bounding_box::BoundingBox,
geometry::{intersection::Intersection, BaseShape, Shape},
point::Point,
ray::Ray,
vector::Vector,
};
#[derive(Debug)]
pub struct TestShape {
base: BaseShape,
pub saved_ray: RwLock<Ray>,
}
impl Default for TestShape... | true |
3b97a2d7bfd8c19eb4a260d35e9f5460af288728 | Rust | IThawk/rust-project | /rust-master/src/test/ui/borrowck/borrowck-move-mut-base-ptr.rs | UTF-8 | 415 | 2.90625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // Test that attempt to move `&mut` pointer while pointee is borrowed
// yields an error.
//
// Example from src/librustc_borrowck/borrowck/README.md
fn foo(t0: &mut isize) {
let p: &isize = &*t0; // Freezes `*t0`
let t1 = t0; //~ ERROR cannot move out of `t0`
*t1 = 22;
p.use_ref();
}
fn main... | true |
6d8861afb4e7c92ecc6df024c4de4ae7a2680814 | Rust | JoNil/loka-n64 | /n64-alloc/src/lib.rs | UTF-8 | 22,715 | 2.515625 | 3 | [] | no_license | #![no_std]
#![allow(clippy::declare_interior_mutable_const)]
#![allow(clippy::cast_ptr_alignment)]
#![allow(clippy::needless_lifetimes)]
extern crate alloc;
mod const_init;
mod imp_static_array;
mod neighbors;
mod size_classes;
use const_init::ConstInit;
use core::alloc::{GlobalAlloc, Layout};
use core::cell::Cell;
... | true |
44f34970a76bfa8e4b1ca3802f1c2a71a62c9339 | Rust | dpjungmin/cmdx | /src/bin/ls.rs | UTF-8 | 3,107 | 3.203125 | 3 | [] | no_license | use cmdx::fs::dir::Dir;
use cmdx::fs::file::File;
use std::convert::TryFrom;
use std::env;
use std::ffi::OsStr;
use std::io::{self, Stdout, Write};
use std::path::PathBuf;
use std::process;
struct Ls<'args> {
writer: Stdout,
paths: Vec<&'args OsStr>,
}
impl<'args> Ls<'args> {
pub fn new(writer: Stdout, pa... | true |
814dd6b6e1a198b6f72fb46149f519120329648b | Rust | TtTRz/RustLib | /code/Mutex/src/main.rs | UTF-8 | 1,272 | 3.640625 | 4 | [] | no_license | use std::sync::{Arc, Mutex};
use std::thread;
// fn main() {
// let counter = Mutex::new(0);
// let mut handles = vec![];
// for _ in 0..10 {
// let handle = thread::spawn(move || {
// let mut num = counter.lock().unwrap(); // counter is moved
// *num += 1;
// });
/... | true |
aee9f9f44f063a842726291fca106a17a18af5df | Rust | swerdloj/jitter | /src/frontend/validate/mod.rs | UTF-8 | 13,233 | 3.125 | 3 | [
"BSD-3-Clause"
] | permissive | pub mod context;
pub mod types;
///////////////////// Validation Helpers /////////////////////
use std::collections::HashMap;
use crate::frontend::validate::types::Type;
use crate::frontend::parse::ast;
///////////////////// TYPES /////////////////////
// NOTE: Offsets are i32 for Cranelift
/// Stores struct defin... | true |
179f25aa1039fbe760717013a726349b61de9b96 | Rust | Busy-Bob/rust_leetcode | /code_0845/src/lib.rs | UTF-8 | 1,875 | 3.015625 | 3 | [] | no_license |
struct Solution;
use std::cmp::max;
impl Solution {
pub fn longest_mountain(a: Vec<i32>) -> i32 {
if a.len() < 3 {
return 0;
}
let mut last_num: i32 = a[0];
let mut increase_flag: bool = false;
let mut decrease_flag: bool = false;
let mut mountain_start... | true |
2474da71ce40574b7d323336005fc66b1e55b746 | Rust | tomtau/tendermint-rs | /tendermint/tests/integration.rs | UTF-8 | 2,832 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | //! Integration tests
/// RPC integration tests.
///
/// These are all ignored by default, since they test against running
/// `tendermint node --proxy_app=kvstore`. They can be run using:
///
/// ```
/// cargo test -- --ignored
/// ```
mod rpc {
use tendermint::rpc::Client;
/// Get the address of the local n... | true |
b758143892a1a994c949020e4f3dd2bd911f2e8f | Rust | sutetako/rust_learning | /src/main.rs | UTF-8 | 51,147 | 3.15625 | 3 | [] | no_license | fn main() {}
#[test]
fn overflow() {
let big_val = std::i32::MAX;
// let x = big_val + 1; // panic
let _x = big_val.wrapping_add(1); // ok
}
#[test]
fn float_test() {
assert_eq!(5f32.sqrt() * 5f32.sqrt(), 5.);
assert_eq!((-1.01f64).floor(), -2.0);
assert!((-1. / std::f32::INFINITY).is_sign_neg... | true |
7b5d0a89563425910397b73621e48fbbab334995 | Rust | azriel91/builder_macro | /src/parse_struct.rs | UTF-8 | 13,149 | 2.8125 | 3 | [
"MIT"
] | permissive | #[doc(hidden)]
#[macro_export]
macro_rules! parse_struct {
// The way we determine visibility of the generated builder and struct is based on the pattern
// in: https://github.com/rust-lang-nursery/lazy-static.rs/blob/v0.2.1/src/lib.rs
// Loop through each meta item in SPEC, extract it and prepend it to IT... | true |
54f5669769e40dab3e6163cdc6654a100263c69a | Rust | actix/actix-website | /examples/server/src/keep_alive.rs | UTF-8 | 840 | 2.515625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use actix_web::{
body::MessageBody,
dev::{ServiceFactory, ServiceRequest, ServiceResponse},
App, Error,
};
#[allow(dead_code)]
fn app() -> App<
impl ServiceFactory<
ServiceRequest,
Response = ServiceResponse<impl MessageBody>,
Config = (),
InitError = (),
Error =... | true |
4a7e27b121f5d5f11b09f015f16fda7eda92c334 | Rust | tiffany352/tiffbot-2 | /irc.rs | UTF-8 | 8,645 | 3.265625 | 3 | [] | no_license | use parse::*;
#[deriving(Clone)]
pub struct Prefix {
nick: ~str,
user: ~str,
host: ~str
}
impl ToStr for Prefix {
fn to_str(&self) -> ~str {
match (self.nick.clone(), self.user.clone(), self.host.clone()) {
(~"", ~"", ~"") => ~"",
(nick, ~"", ~"") => nick,
(... | true |
cffec2d5396c808b41efe766d1892dfe78d6acf8 | Rust | escape209/chum-world | /libchum/src/macros.rs | UTF-8 | 42,890 | 2.640625 | 3 | [
"MIT"
] | permissive | #[allow(unused_macros)]
macro_rules! chum_path_element {
( [$x:expr] ) => {
ChumPathElement::Index($x)
};
( $x:expr ) => {
ChumPathElement::Member(&stringify!($x))
};
}
#[macro_export]
macro_rules! chum_path {
( $( $x:tt). * ) => {
&[
$(
chum_path... | true |
d91ad2c77008847391443fdbdb90193a298063f9 | Rust | FroVolod/cli_dialoguer_strum_2 | /src/main.rs | UTF-8 | 1,550 | 2.53125 | 3 | [] | no_license | use structopt::StructOpt;
pub(crate) mod common;
pub(crate) mod utils_subcommand;
mod consts;
mod command;
use command::{
CliCommand,
ArgsCommand,
};
#[derive(Debug)]
struct Args {
subcommand: ArgsCommand,
}
#[derive(Debug, Default, StructOpt)]
struct CliArgs {
#[structopt(subcommand)]
subcomman... | true |
b98750f41f8a9a20a8a2345ddae3a33b2612fc03 | Rust | HerringtonDarkholme/leetcode | /src/1372_longest_zig_zag.rs | UTF-8 | 977 | 3.234375 | 3 | [] | no_license | // Definition for a binary tree node.
// #[derive(Debug, PartialEq, Eq)]
// pub struct TreeNode {
// pub val: i32,
// pub left: Option<Rc<RefCell<TreeNode>>>,
// pub right: Option<Rc<RefCell<TreeNode>>>,
// }
//
// impl TreeNode {
// #[inline]
// pub fn new(val: i32) -> Self {
// TreeNode {
// val,... | true |
10f4c1df8234ec147a09f1bd0042a37405fed780 | Rust | nikgaevoy/nimber | /src/derive.rs | UTF-8 | 1,960 | 3.1875 | 3 | [] | no_license | use super::Nimber;
use std::cmp::Ordering;
use std::fmt::{Debug, Formatter};
use std::hash::{Hash, Hasher};
impl<T: Clone> Clone for Nimber<T> {
#[inline]
fn clone(&self) -> Self {
Self { x: self.x.clone() }
}
#[inline]
fn clone_from(&mut self, source: &Self) {
self.x.clone_from(&... | true |
d7c98f60cc77ed69e5467aa6901d68c2d001083c | Rust | rhyadav/byte_buffer | /byte_buffer/src/lock.rs | UTF-8 | 741 | 2.90625 | 3 | [
"MIT"
] | permissive | use std::io::ErrorKind;
use std::sync::atomic::{self, AtomicBool, Ordering};
const LOCK_TIMEOUT: usize = 64;
static LOCK: AtomicBool = AtomicBool::new(false);
pub(crate) fn lock() -> Result<(), ErrorKind> {
let mut count = 1;
loop {
if let Ok(true) = LOCK.compare_exchange(false, true, Ordering::Acqui... | true |
b49a0dbaf1623e8e89ffe0ba2594d4095b6c9828 | Rust | g-cl/sit | /sit/tests/command_reduce.rs | UTF-8 | 5,266 | 2.828125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | extern crate cli_test_dir;
extern crate sit_core;
extern crate serde_json;
use sit_core::{Repository, Item};
use cli_test_dir::*;
include!("includes/config.rs");
/// Should fail if there is no item to reduce
#[test]
fn no_item() {
let dir = TestDir::new("sit", "no_item");
dir.cmd()
.arg("init")
... | true |
ec91255412f66b59dc4d774c3430389da4c70920 | Rust | trentearl/news | /src/main.rs | UTF-8 | 3,045 | 2.796875 | 3 | [] | no_license | extern crate ncurses;
extern crate redis;
extern crate reqwest;
extern crate term_size;
extern crate termion;
mod net;
mod news;
use rss::Channel;
use std::io::BufReader;
use std::io::{stdin, stdout, Write};
use crate::net::get_and_cache_url;
use crate::news::print_headlines;
use crate::news::print_article;
use term... | true |
8a318e67829f608c17dc13f566774351d50e0cb0 | Rust | HeroicKatora/rust-aliasable | /src/vec.rs | UTF-8 | 5,163 | 3.421875 | 3 | [
"MIT"
] | permissive | //! Aliasable `Vec`.
use core::ops::{Deref, DerefMut};
use core::pin::Pin;
use core::ptr::NonNull;
use core::{fmt, mem, slice};
pub use alloc::vec::Vec as UniqueVec;
/// Basic aliasable (non `core::ptr::Unique`) alternative to
/// [`alloc::vec::Vec`].
pub struct AliasableVec<T> {
ptr: NonNull<T>,
len: usize,... | true |
0296e65dc395c5dbf1f6c743fd7a62a369dbc0e8 | Rust | toshuno/solved_problems | /atcoder/ABC/016C.rs | UTF-8 | 2,265 | 3.03125 | 3 | [] | no_license |
fn main() {
let mut sc = Scanner::new();
let n: usize = sc.read();
let m: usize = sc.read();
let mut connect: Vec<Vec<usize>> = vec![vec![]; n];
for _ in 0..m {
let a: usize = sc.read();
let b: usize = sc.read();
connect[a - 1].push(b - 1);
connect[b - 1].push(a - 1)... | true |
5ccc9c8963cfcfc3e0a95214e3e5ac8b18a01938 | Rust | mvolkmann/rust-parallel-options | /src/main.rs | UTF-8 | 1,925 | 2.78125 | 3 | [] | no_license | use std::error::Error;
/*
mod std_demo;
use std_demo::{concurrent, parallel_tasks, parallel_threads, serial};
fn main() -> Result<(), Box<dyn Error>> {
let (sum1, sum2) = serial()?;
println!("serial: sum1 = {:?}, sum2 = {:?}", sum1, sum2);
let (sum1, sum2) = concurrent()?;
println!("concurrent: sum1 =... | true |
44b8bd650ebb8214bb4034f702c8018600031ba5 | Rust | pkage/focusd | /src/main.rs | UTF-8 | 4,669 | 2.921875 | 3 | [] | no_license | use colored::*;
use clap::Parser;
mod hosts;
mod time;
mod config;
mod client;
mod messages;
mod common;
mod server;
#[derive(Parser)]
#[clap(version="0.0.2", author="Patrick Kage (patrick@ka.ge)", about="Automatically manage /etc/hosts to lock out distracting websites for a finite period.")]
struct Opts {
#[clap... | true |
b49140afbd5bd3bb803eae3fad6eeab4a3c87606 | Rust | miker1423/signalr-rs | /serializer_test/src/main.rs | UTF-8 | 5,587 | 2.921875 | 3 | [] | no_license | use serde::{Serialize, Deserialize};
use serde_json::Value;
#[derive(Debug)]
enum MessageVariants {
Invocation(InvocationFields), //type = 1
StreamItem(StreamItemFields), // type = 2
Completion(CompletionFields),//type = 3
StreamInvocation(StreamInvocationFields), //type = 4
CancelInvokation(Cancel... | true |
6279a66b99c2860d9dd96535856bbdc274f6e8f5 | Rust | INDAPlus21/dpeilitz-task-2 | /avstand_till_kanten/src/main.rs | UTF-8 | 1,656 | 3.109375 | 3 | [] | no_license | /***
* Template to a Kattis solution.
* See: https://open.kattis.com/help/rust
* Author: Viola Söderlund <violaso@kth.se>
*/
// HEAVILY INSPIRED BY FELIX MURNION'S SOLUTION
use std::io;
use std::io::prelude::*;
use std::char;
// Kattis calls main function to run your solution.
fn main() {
// get standard inp... | true |
dbadcaf2efcb449eff66fa82ff12bed7a5ef9a8a | Rust | johnae/persway | /src/node_ext.rs | UTF-8 | 5,830 | 3.03125 | 3 | [
"MIT"
] | permissive | use anyhow::{anyhow, Result};
use async_trait::async_trait;
use swayipc_async::{Connection, Node, NodeLayout, NodeType, Workspace};
pub enum RefinedNodeType {
Root,
Output,
Workspace,
Container, // doesn't directly contain an application
FloatingContainer, // doesn't directly contain an app... | true |
b91cd2ca119dab2425b85145ae607d7a755dc1f4 | Rust | mcbunkus/Orbital | /hw5/src/body.rs | UTF-8 | 10,893 | 3.234375 | 3 | [] | no_license | #![allow(dead_code)]
#![allow(unused_doc_comments)]
/**
* body.rs contains the Body struct and implements methods for it. A body struct contains only the
* position and velocity vectors of the body, other parameters are calculated using methods. A body
* is instantiated using using the Body::new() method, which als... | true |
b24853edb83ad9aab5c808aa0d8281ba9d7d3957 | Rust | azula-lang/azula | /typecheck/src/typecheck.rs | UTF-8 | 53,036 | 2.84375 | 3 | [
"MIT"
] | permissive | use std::{collections::HashMap, ops::Deref, rc::Rc};
use azula_ast::prelude::*;
use azula_error::prelude::*;
use azula_type::prelude::AzulaType;
pub struct Typechecker<'a> {
ast: Statement<'a>,
functions: HashMap<&'a str, FunctionDefinition<'a>>,
globals: HashMap<String, VariableDefinition<'a>>,
stru... | true |
e1d3086bf8b79d0d6cfbc3e8c3dc66cf1cf9fc4c | Rust | rodrimati1992/core_extensions | /src_core_extensions/phantom.rs | UTF-8 | 8,523 | 3.5 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | //! `PhantomData`-related items.
//!
use std_::{
cell::Cell,
marker::PhantomData,
};
/// Type alias for a variant `PhantomData` with drop check.
///
/// # Example
///
/// ```rust
/// use core_extensions::VariantDropPhantom;
/// use std::marker::PhantomData;
///
/// let _: VariantDropPhantom<u32> = PhantomD... | true |
469df8f0f65b460738995cd7d99cc462176fb70e | Rust | erazor-de/ppatch | /src/searcher.rs | UTF-8 | 1,961 | 3.03125 | 3 | [
"MIT"
] | permissive | use crate::{Pattern, PatternSearchType};
use std::fmt;
use std::mem;
use std::ops;
pub struct Searcher<'a, T> {
pattern: &'a Pattern<T>,
matched: bool,
data: Vec<T>,
taken: usize,
}
impl<'a, T> Searcher<'a, T>
where
T: From<u8>
+ fmt::Binary
+ num::PrimInt
+ num::Unsigned
... | true |
c2e82a8f09d984663533598839471ec5db9eed9d | Rust | MinaProtocol/mina | /src/lib/crypto/kimchi_bindings/stubs/src/arkworks/pasta_fq.rs | UTF-8 | 8,353 | 2.5625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::arkworks::CamlBigInteger256;
use crate::caml::caml_bytes_string::CamlBytesString;
use ark_ff::ToBytes;
use ark_ff::{FftField, Field, FpParameters, One, PrimeField, SquareRootField, UniformRand, Zero};
use ark_poly::{EvaluationDomain, Radix2EvaluationDomain as Domain};
use mina_curves::pasta::{fields::fq::FqP... | true |
e5deea234b818d035e5914e490d3c5a4c4ba88c9 | Rust | jimblandy/swgl-replay | /gl-replay/src/pixels.rs | UTF-8 | 6,669 | 3.21875 | 3 | [] | no_license | //! Serializing and deserializing blocks of pixels.
//!
//! This module's `Pixels` type represents a rectangular block of pixels in
//! memory (up to three dimensions), with an associated OpenGL format and pixel
//! type. It can either borrow or own the pixels.
//!
//! A `Pixels` value can be serialized and deserialize... | true |
00332591018b1e5d74136211fc532718ca99fce3 | Rust | alvaro7rlz/rust-cql | /src/error.rs | UTF-8 | 1,142 | 2.546875 | 3 | [] | no_license |
extern crate std;
use std::net::{Ipv4Addr,Ipv6Addr,SocketAddr,IpAddr};
use uuid::Uuid;
use std::borrow::Cow;
use std::ops::Deref;
use std::error::Error;
use def::CowStr;
#[derive(Debug,Clone)]
pub enum RCErrorType {
ReadError,
WriteError,
SerializeError,
ConnectionError,
NoDataError,
GenericE... | true |
373b10bd10b4cc678661e3e77b7500138f11eaae | Rust | fabiojmendes/rust-game | /src/main.rs | UTF-8 | 3,025 | 3.03125 | 3 | [] | no_license | use std::thread;
use std::time::{Duration, Instant};
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::pixels::Color;
use sdl2::render::{Texture, WindowCanvas};
// "self" imports the "image" module itself as well as everything else we listed
use sdl2::image::{self, InitFlag, LoadTexture};
use sdl2::rect::... | true |
317bf1de16467fbeae40dccf3617a08ba64d33c6 | Rust | AlexHart/rust-book | /slices/src/main.rs | UTF-8 | 1,241 | 4.09375 | 4 | [] | no_license | fn main() {
let s = String::from("Lorem ipsum dolor sit amet");
let hello = &s[0..5];
let world = &s[6..11];
println!("{} {}", hello, world);
let fw = first_word(&s);
println!("First word: {}", fw);
let sw = second_word(&s);
println!("Second word: {}", sw);
// Vec slices example... | true |
b84e701208911963c56d11958662b555830f46ff | Rust | bbqsrc/export | /export_test/src/lib.rs | UTF-8 | 517 | 3.0625 | 3 | [] | no_license | #[export::unstable]
/// Have some docs
///
/// Have some anger
fn lolwut() {
println!("yes");
}
#[must_use]
pub fn lolwut2() {
println!("yes");
}
#[export::unstable]
fn lolwut3() {
println!("yes");
}
#[export::unstable]
/// If I document this
///
/// Is it happy?
mod lolmod {
#[export::unstable]
... | true |
4036a9f7fd555c94ca9aba913bdf4a02b6a43faf | Rust | oc-soft/glrs | /src/geom/d2.rs | UTF-8 | 6,806 | 2.75 | 3 | [] | no_license | use crate::geom;
use crate::geom::GeomError;
use crate::Segment;
pub struct D2 {}
impl D2 {
/// move each points offset along to line(p1 p2) normal vector
pub fn offset_points_0(
offset: f64,
p1: &[f64],
p2: &[f64],
tolerance: f64,
) -> Result<[Vec<f64>; 2], GeomError> {
... | true |
a2950bb88bf8385099e5e0f43ef6ec3ef66da516 | Rust | iCodeIN/Lil.rs | /src/main.rs | UTF-8 | 2,658 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | use std::io;
use std::io::Write;
mod ast;
mod lexer;
mod parser;
mod typer;
mod source_map;
mod type_map;
mod error;
use crate::parser::Parser;
use crate::parser::Error;
use crate::typer::TypeChecker;
use crate::source_map::SourceMap;
use crate::type_map::TypeMap;
use crate::error::SyntaxError;
use crate::ast::Abstra... | true |
68c39db03303ab46ef3e822f3cac40694b4c8e7f | Rust | nathanfaucett/rs-scene_renderer | /tests/test.rs | UTF-8 | 2,984 | 2.625 | 3 | [
"MIT"
] | permissive | #![feature(alloc)]
#![feature(collections)]
#![no_std]
extern crate alloc;
extern crate collections;
extern crate shared;
extern crate scene_graph;
extern crate scene_renderer;
use shared::Shared;
use scene_graph::{Id, Scene};
use scene_renderer::{SceneRenderer, Renderer, Plugin};
struct SomeRendererData {
... | true |
5559630c3c01b1537c3952b2bb64beeb4beab319 | Rust | SoundRabbit/soldoresol | /src/arena.org/block/character.rs | UTF-8 | 9,904 | 2.90625 | 3 | [] | no_license | use super::block_trait::DisplayNamed;
use super::BlockId;
use crate::arena::resource::ResourceId;
use crate::libs::color::Pallet;
use crate::libs::select_list::SelectList;
#[derive(Clone)]
pub struct CharacterTexture {
name: String,
texture_id: Option<ResourceId>,
height: f32,
}
#[derive(Clone)]
pub struc... | true |
52b63947742f76fb45929ae19f9785d27cb7d9c7 | Rust | rm-rf-etc/basic_ml_in_rust | /src/shared.rs | UTF-8 | 384 | 2.765625 | 3 | [] | no_license | use super::ml::Matrix2D;
#[allow(dead_code)]
pub fn round(f: f32) -> f32 {
let prec = 100000.0;
(f * prec).round() / prec
}
#[allow(dead_code)]
pub fn assert_matrices_eq(mat: &Matrix2D, exp_mat: &Matrix2D) {
let y = mat.shape()[0];
let x = mat.shape()[1];
for (i, j) in (0..y).zip(0..x) {
... | true |
87224fd3b23c50c6941404e062ce50e43c05af04 | Rust | iambotHQ/zalando-api-client | /src/models/brand.rs | UTF-8 | 2,857 | 2.53125 | 3 | [] | no_license | /*
* Zalando Shop API
*
* The shop API empowers developers to build amazing new apps or websites using Zalando shop data and services.
*
* OpenAPI spec version: v1.0
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
/// Brand : Zalando API Brand Schema
#[derive(Debug, Serialize, Deseri... | true |
9d6cf3fc71071e5eb81d63d8fabf2d75a7968113 | Rust | gba-rs/gba-emu | /src/thumb_formats/multiple_load_store.rs | UTF-8 | 5,293 | 3.015625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::operations::instruction::Instruction;
use crate::cpu::{cpu::CPU, cpu::THUMB_PC};
use crate::memory::memory_bus::MemoryBus;
use std::fmt;
pub struct MultipleLoadStore {
pub opcode: u8,
pub rb: u8,
pub register_list: Vec<u8>,
pub load: bool
}
impl From<u16> for MultipleLoadStore {
fn fro... | true |
a8464339d6a1e3ab076e015edb6f726e7f99907e | Rust | Fiedzia/rust-instrumentation | /src/instrumentation/utils.rs | UTF-8 | 406 | 3.5625 | 4 | [] | no_license | pub fn dotsplit(s:~str) -> (~str, Option<~str>) {
//! Split string s into two parts, separated by first . character.
//! This functions assumes that s is not empty
//! ie. ~"foo.bar" -> ~"foo", Some(~"bar")
//! ~"foo" -> ~"foo", None
match s.find_str(&".") {
None => (s, None),
Some(i... | true |
1703b7f7f27620d71bba67955c06ceb68d7bc6e2 | Rust | bombless/rusti | /tests/repl.rs | UTF-8 | 1,570 | 3.34375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::process::Command;
fn repl_run(args: &[&str]) -> String {
let rusti = if cfg!(windows) { "target/debug/rusti.exe" } else { "target/debug/rusti" };
match Command::new(rusti).args(args).env("HOME", "data").output() {
Ok(out) => String::from_utf8(out.stdout).unwrap(),
Err(e) => panic!("fa... | true |
c5fcfedba3054f43094199f9e9f47857cf4250d8 | Rust | romatthe/remoc | /remoc/src/rch/mpsc/receiver.rs | UTF-8 | 13,151 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | use bytes::Buf;
use futures::{ready, FutureExt};
use serde::{Deserialize, Serialize};
use std::{
error::Error,
fmt,
marker::PhantomData,
sync::Mutex,
task::{Context, Poll},
};
use super::{
super::{
base::{self, PortDeserializer, PortSerializer},
buffer, RemoteSendError, BACKCHAN... | true |
2e41826ce1589665d1a52b16c31c7d747cfd6456 | Rust | tifennf/tiplouf | /tests/api_route.rs | UTF-8 | 7,164 | 3 | 3 | [] | no_license | // YOU need to start mongod, then `cargo run` to start the server, then you can `cargo test`
use reqwest::Response;
use reqwest::StatusCode;
use reqwest::header;
use serde_json::Value;
use std::collections::HashSet;
use fake::{Dummy, Fake, Faker};
use serde::{Deserialize, Serialize};
use serde_json::json;
const IP:... | true |
6ca68551bc27bc5de465a535597e56c9bad241ef | Rust | v33ps/mischief | /src/main.rs | UTF-8 | 7,147 | 2.625 | 3 | [] | no_license | use std::net::{TcpStream, TcpListener};
use std::io::{Read, Write};
use std::thread;
use serde_json::{Error};
// #[allow(unused_imports)]
use serde::{Serialize, Deserialize};
#[allow(unused_imports)]
use crossbeam_channel::{unbounded, RecvError, TryRecvError};
#[allow(unused_imports)]
use crossbeam_channel::{Receiver, ... | true |
6edd313651181ad625b7380bb55f0c146708375b | Rust | madadam/xor-name | /src/xorable.rs | UTF-8 | 15,091 | 3.109375 | 3 | [
"BSD-3-Clause",
"MIT"
] | permissive | // Copyright 2020 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
// https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied,
// modified, or di... | true |
f8278ca780bd7d0c846c78a3273e2f7bab02344e | Rust | XOSplicer/codingame-solutions | /puzzles/community/langtons_ant.rs | UTF-8 | 4,463 | 3.109375 | 3 | [] | no_license | use std::io;
use std::io::BufRead;
macro_rules! print_err {
($($arg:tt)*) => (
{
use std::io::Write;
writeln!(&mut ::std::io::stderr(), $($arg)*).ok();
}
)
}
macro_rules! parse_input {
($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap())
}
#[derive(Debug, Part... | true |
e5ebf947b4e16b688c0e2976d4f20a66515155ab | Rust | kolen/rustzx | /src/zx/controller.rs | UTF-8 | 15,328 | 2.78125 | 3 | [
"MIT"
] | permissive | //! Contains ZX Spectrum System contrller (like ula or so) of emulator
use std::fs::File;
use std::io::Read;
use std::path::{Path, PathBuf};
// use almost everything :D
use utils::{split_word, Clocks};
use utils::screen::*;
use utils::events::*;
use utils::InstantFlag;
use z80::Z80Bus;
use zx::{ZXMemory, RomType, RamT... | true |
230ac50a7480fe92b261ea7e0b88a608e80178f7 | Rust | troyvassalotti/days-of-rustmas | /src/main.rs | UTF-8 | 902 | 3.265625 | 3 | [] | no_license | fn main() {
let days = ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"];
let lyrics = ["A partridge in a pear tree", "Two turtle doves, and", "Three french hens", "Four calling birds", "Five golden rings", "Six geese a-laying", "Seven swans ... | true |
7583c79a59298c3745e087c7eb08fdea35e28e84 | Rust | r-asou/databend | /common/functions/src/aggregates/aggregator_common.rs | UTF-8 | 2,243 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to ... | true |
035f752cce4ecd96938689301838d7b13217ac49 | Rust | NonJam/shipyard | /src/sparse_set/sparse_array/mod.rs | UTF-8 | 3,045 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | mod sparse_slice;
mod sparse_slice_mut;
pub(crate) use sparse_slice::SparseSlice;
pub(crate) use sparse_slice_mut::SparseSliceMut;
use crate::storage::EntityId;
#[cfg(not(feature = "std"))]
use alloc::boxed::Box;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
pub(crate) struct SparseArray<T>(Vec<Option<Box<T>>>);... | true |
d19fc4e5e52369e26f34f39766d0550e9afe3fdc | Rust | 5l1v3r1/vita | /src/sources/binaryedge.rs | UTF-8 | 2,531 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Unlicense"
] | permissive | use crate::error::Result;
use crate::IntoSubdomain;
use async_std::task;
use dotenv::dotenv;
use serde::Deserialize;
use std::collections::HashSet;
use std::env;
use std::sync::Arc;
#[derive(Deserialize)]
struct BinaryEdgeResponse {
page: i32,
pagesize: i32,
total: i32,
events: Vec<String>,
}
impl Int... | true |
e044091a941bf1603dd463136c2afa14fd9cb9c8 | Rust | cyndis/jis0208 | /map.rs | UTF-8 | 633,080 | 2.75 | 3 | [] | no_license | use std::mem::transmute;
pub fn decode(codepoint: u16) -> Option<char> {
match codepoint {
0x2121 => Some(unsafe { transmute(0x3000u32) }),
0x2122 => Some(unsafe { transmute(0x3001u32) }),
0x2123 => Some(unsafe { transmute(0x3002u32) }),
0x2124 => Some(unsafe { transmute(0xff0cu32) ... | true |
f45cd9dc0b809274b04f98d6b9d6b9b669dd68b3 | Rust | kjagiello/pacgen | /src/server.rs | UTF-8 | 2,028 | 2.609375 | 3 | [
"MIT"
] | permissive | use chrono;
use log::{error, info};
use std::net::SocketAddr;
use std::sync::Arc;
use hyper::server::conn::AddrStream;
use hyper::service::{make_service_fn, service_fn};
use hyper::{Body, Error, Method, Request, Response, Server, StatusCode};
pub struct Config {
pub addr: SocketAddr,
pub pac: String,
}
struc... | true |
a1bb97a991cd7e6be1ea6280df694532b44b0ce9 | Rust | tungli/lsode-rust | /tests/solve_ode.rs | UTF-8 | 2,172 | 2.90625 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | extern crate lsode;
// To run tests, use --test-threads=1. Multiple threads cause trouble (reason is unknown to me).
fn solution_stiff(t: f64) -> [f64; 2] {
[
2.0*(-t).exp() - (-(1000.0*t)).exp(),
-((-t).exp()) + (-(1000.0*t)).exp()
]
}
fn rhs_stiff(y: &[f64], _t: &f64) -> Vec<f64> {
let... | true |
346a5f9631c3c6e7c79f3a0feab451338ed4cbf2 | Rust | simsarulhaqv/WorksOnRust | /Rustworkshop/src/part06.rs | UTF-8 | 281 | 3.3125 | 3 | [] | no_license | // Strings are unicode unlike ascii in C/C++
fn print_me_2(s: String) {
println!("I am {}",s);
}
pub fn print_me(s:&str) {
println!("I am {}", s);
}
pub fn main() {
println!("hello world");
let f = "simsar";
print_me(&f);
let f = "SIMSAR";
print_me_2(f.to_string());
}
| true |
71c0d672e2d0708f32eae8f597d791203adec27a | Rust | isgasho/log-derive | /src/lib.rs | UTF-8 | 9,046 | 2.984375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![recursion_limit = "128"]
//! # Log Derive
//!
//! `log-derive` provides a simple attribute macro that facilitates logs as part of the [`log`] facade <br>
//! Right now the only macro is [`logfn`], this macro is only for functions but it still have a lot of power.
//!
//!
//! # Use
//! The basic use of the macro is... | true |
68d4cc7422695eb4c7a8c6b2548b08020dbb262c | Rust | mdeg/dexparser | /src/error.rs | UTF-8 | 3,091 | 3.046875 | 3 | [
"MIT"
] | permissive | use failure::Fail;
#[derive(Debug, Fail, Clone)]
pub enum DexParserError {
#[fail(display = "file unexpectedly ended early: expected {} bytes", needed)]
EndedEarly {
needed: usize
},
#[fail(display = "could not parse file: {}", reason)]
ParsingFailed {
reason: String
},
#[fa... | true |
cb712978afbc0706f1f5ae95e2eff047eaf4eb9e | Rust | tan-wei/genet | /genet-abi/src/error.rs | UTF-8 | 957 | 3.109375 | 3 | [
"MIT"
] | permissive | use std::{error, fmt, str};
use string::SafeString;
/// An error object.
#[repr(C)]
#[derive(Clone, PartialEq)]
pub struct Error {
desc: SafeString,
}
impl Error {
/// Creates a new Error.
pub fn new(desc: &str) -> Error {
Self {
desc: SafeString::from(desc),
}
}
}
impl fm... | true |
a096443d4c217615c253cfd8b5582e34f4dd06ab | Rust | ginglis13/rustutils | /env/src/main.rs | UTF-8 | 833 | 2.828125 | 3 | [] | no_license | // env
// written to work on Unix machines
extern crate getopts;
use getopts::Options;
use std::env;
fn usage(program: &str, opts: &Options) {
let brief = format!("Usage: {} [OPTION] FILE", program);
print!("{}", opts.usage(&brief));
}
fn env() {
for (k,v) in env::vars() {
println!("{}={}", ... | true |
86058a6c5a5109988eb77647b35a5036b4df9c94 | Rust | mbarbier/wasm-gl | /src/game.rs | UTF-8 | 2,693 | 2.71875 | 3 | [] | no_license | use std::{cell::RefCell, rc::Rc};
use cgmath::{vec3, Deg, Matrix4, Point3, Quaternion, Rotation3, Transform};
use js_sys::Date;
use wasm_bindgen::JsValue;
use weblog::{console_error, console_log};
use crate::core::{
geometry::Geometry,
graph::Node,
material::Material,
object3d::{Mesh, Object3d},
r... | true |
0be7b5ebb92e3631124af0eea855fcb40b69c924 | Rust | fisherdarling/asterix | /asterix-impl/src/visitor.rs | UTF-8 | 9,367 | 2.53125 | 3 | [] | no_license | use std::collections::HashSet;
use proc_macro2::{Span, TokenStream};
use quote::{format_ident, quote, ToTokens, TokenStreamExt};
use syn::{spanned::Spanned, Ident};
use crate::context::{Context, EnumType, NewType};
pub struct Visitor<'c> {
pub new_idents: HashSet<String>,
context: &'c Context,
}
impl<'c> Vi... | true |
6bb0f2e3290db081b70e1df44ce561ba7ce26211 | Rust | dmshvetsov/adventofcode | /2022/07/2.rs | UTF-8 | 2,689 | 3.046875 | 3 | [] | no_license | use std::collections::HashMap;
use std::fs::File;
use std::io::{BufRead, BufReader};
const MAX: u64 = 70_000_000;
const REQUIRED: u64 = 30_000_000;
fn solution(input: BufReader<File>) -> u64 {
let mut total = 0;
let mut dir_stack: Vec<String> = Vec::new();
let mut dir_sizes = HashMap::new();
for line... | true |
5047827f79df5e7170ba639be28b7c94eeb22651 | Rust | henkkuli/rp-hal | /rp2040-hal/src/pll.rs | UTF-8 | 8,579 | 3.09375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Phase-Locked Loops (PLL)
// See [Chapter 2 Section 18](https://datasheets.raspberrypi.org/rp2040/rp2040_datasheet.pdf) for more details
use core::{
convert::{Infallible, TryFrom, TryInto},
marker::PhantomData,
ops::{Deref, Range, RangeInclusive},
};
use embedded_time::{
fixed_point::FixedPoint,
... | true |
49d65521ee5adeddf4e4b0c8407f31b7ee30a8be | Rust | alishahusain/reserves | /src/context.rs | UTF-8 | 3,227 | 2.625 | 3 | [
"CC0-1.0"
] | permissive | use std::fs;
use clap;
use protobuf;
use protobuf::Message;
use common;
use protos;
use utils;
pub fn global_args<'a>() -> Vec<clap::Arg<'a, 'a>> {
vec![
clap::Arg::with_name("verbose")
.short("v")
.multiple(true)
.takes_value(false)
.help("print verbose logging output to stderr")
.global(true),
... | true |
8c219b80acfce5c1d7104e83a395a319f4149b5e | Rust | thomvil/job-manager-rs | /src/model/job.rs | UTF-8 | 3,469 | 3.28125 | 3 | [] | no_license | use crate::prelude::*;
#[derive(Clone, Debug)]
pub struct Job {
pub(crate) id: Option<usize>,
pub(crate) load: String,
pub(crate) difficulty: u8,
pub(crate) started_at: Option<DateTime<Local>>,
pub(crate) completed_at: Option<DateTime<Local>>,
pub(crate) persistant: bool... | true |
383d1081bd84beb09e2d8bf438a76d6803e0dff2 | Rust | carsonaco/chain | /client-core/src/key/private_key.rs | UTF-8 | 2,762 | 3 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use failure::ResultExt;
use rand::rngs::OsRng;
use secp256k1::{PublicKey as SecpPublicKey, SecretKey};
use zeroize::Zeroize;
use client_common::{ErrorKind, Result};
use crate::{PublicKey, SECP};
/// Private key used in Crypto.com Chain
#[derive(Debug, PartialEq)]
pub struct PrivateKey(SecretKey);
impl PrivateKey {
... | true |
2e72a688820cfadbf787deb8a9364990d8df2f80 | Rust | touilleMan/orion | /src/high_level/kdf.rs | UTF-8 | 7,900 | 2.921875 | 3 | [
"MIT"
] | permissive | // MIT License
// Copyright (c) 2020-2021 The orion Developers
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, cop... | true |
cdb78a2fe93f5fe9c52b6970911b26193672e319 | Rust | barreiro/euler | /src/main/rust/euler/solver086.rs | UTF-8 | 3,087 | 3.015625 | 3 | [
"MIT"
] | permissive | // COPYRIGHT (C) 2017 barreiro. All Rights Reserved.
// Rust solvers for Project Euler problems
use algorithm::cast::Cast;
use algorithm::factor::proper_factors_of;
use algorithm::root::square;
use Solver;
/// A spider, `S`, sits in one corner of a cuboid room, measuring `6` by `5` by `3`, and a fly, `F`, sits in the... | true |
b11372d58dabb97d94a43577b61d53adc13f6e3a | Rust | Isaac-Lozano/i3status-rs | /src/block/time.rs | UTF-8 | 589 | 3.1875 | 3 | [
"MIT"
] | permissive | //! A quick time block. Spits out the output of strftime and updates once a
//! second.
use block::{Block, Status};
use chrono::offset::local::Local;
use std::time::Duration;
#[derive(Debug)]
pub struct Time<'a> {
format: &'a str,
}
impl<'a> Time<'a> {
pub fn new(format: &'a str) -> Time<'a> {
Time {... | true |
a13461043540fa9fe531a7cdea2265376d286596 | Rust | grogers0/advent_of_code | /2021/day16/src/main.rs | UTF-8 | 9,145 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::io::{self, Read};
struct BitString(Vec<u8>);
impl BitString {
fn from_hex(s: &str) -> Self {
fn hex_ch(ch: u8) -> u8 {
match ch {
b'A'..=b'F' => ch - b'A' + 10,
b'0'..=b'9' => ch - b'0',
_ => panic!()
}
}
let ... | true |
2ed957ca65b508452238af74bda12846a610fab9 | Rust | TheMindCompany/signedurl | /src/daemon/response.rs | UTF-8 | 1,369 | 2.828125 | 3 | [
"MIT"
] | permissive | #[derive(Serialize, Deserialize, Debug, Default, Clone)]
pub struct SignedUrlResponse {
pub data: SignedUrlData,
}
impl SignedUrlResponse {
pub fn new() -> SignedUrlResponse {
Default::default()
}
pub fn set_attributes(&mut self, val: SignedUrlAttributes) {
self.data.set_attributes(va... | true |
a7b7adbb9f2e412a5afbaeaf5241cd3741310744 | Rust | IThawk/rust-project | /rust-master/src/test/ui/privacy/private-impl-method.rs | UTF-8 | 311 | 2.890625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | mod a {
pub struct Foo {
pub x: isize
}
impl Foo {
fn foo(&self) {}
}
}
fn f() {
impl a::Foo {
fn bar(&self) {} // This should be visible outside `f`
}
}
fn main() {
let s = a::Foo { x: 1 };
s.bar();
s.foo(); //~ ERROR method `foo` is private
}
| true |
0429763036368c39e39e8c7ca03ba88abaf47760 | Rust | neoeinstein/advent-of-code-2019 | /src/day12.rs | UTF-8 | 23,013 | 3.78125 | 4 | [] | no_license | //! # Day 12: The N-Body Problem
//!
//! The space near Jupiter is not a very safe place; you need to be careful of a
//! big distracting red spot, extreme radiation, and a whole lot of moons
//! swirling around. You decide to start by tracking the four largest moons: Io,
//! Europa, Ganymede, and Callisto.
//!
//! Aft... | true |
ee0c04f480e062a6bad7ac32fe0c6dde0277e706 | Rust | zeerorg/A-I-Rust | /src/algo/dfid.rs | UTF-8 | 3,245 | 3.203125 | 3 | [] | no_license | use std::hash::Hash;
use std::collections::HashSet;
use std::fmt::Display;
use helper::node::*;
pub fn dfid<T: PartialEq + Hash + Eq + Clone + Display> (start: &T, goal_function: &Fn(&T) -> bool, _functions: &Vec<&Fn(&T) -> T>) -> bool {
let mut prev_node_count = 0;
let mut depth_allowed = 1;
loop {
... | true |
10e9166867cbef4f976a440f7350f264befc5618 | Rust | kwyse/altitude | /src/delegator.rs | UTF-8 | 3,051 | 3.46875 | 3 | [] | no_license | use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use entities::{Position, Velocity};
/// Controls an entity, such as through user input or through AI.
pub trait Delegator {
/// The object that the delegator controls.
type Delegate;
/// The object controlling the delegate.
type Delegator;
/// ... | true |
fce188bf039f256cf3811815cef71a24b2620df0 | Rust | tengrommel/lesson | /Algorithm/lesson1/ex-sorting/src/lib.rs | UTF-8 | 4,756 | 3.46875 | 3 | [] | no_license | mod rand;
use std::fmt::Debug;
use rayon::prelude::*;
pub fn bubble_sort<T: PartialOrd + Debug>(v: &mut [T]) {
for p in 0..v.len() {
// println!("{:?}", v);
let mut sorted = true;
for i in 0..(v.len()-1) - p{
if v[i] > v[i+1] {
v.swap(i, i+1);
so... | true |
16c8f88a090c1088719d98d388a90e6f6c515118 | Rust | carribus/rust-game-experiments | /ggez-test2/src/components.rs | UTF-8 | 467 | 2.734375 | 3 | [] | no_license | use ggez::graphics::Color;
#[derive(Debug, Copy, Clone, Default, PartialEq)]
pub struct Position {
pub x: f32,
pub y: f32,
}
#[derive(Debug, Copy, Clone, Default, PartialEq)]
pub struct Velocity {
pub xv: f32,
pub yv: f32,
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum ShapeType {
Rectangle(... | true |
376013f1f1730af17eb85e5bb729afb50ae4f805 | Rust | tarkah/nhl-notifier | /src/cli.rs | UTF-8 | 2,288 | 2.96875 | 3 | [
"MIT"
] | permissive | use crate::config::{generate_empty_config, AppConfig};
use failure::{bail, Error, ResultExt};
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(
name = "nhl-notifier",
about = "Get live game updates via SMS for your favorite NHL team.",
version = "0.1.0",
author ... | true |
87357fd50e310644a20f3dc6f1172c96f8c09296 | Rust | horellana/yofi | /src/usage_cache.rs | UTF-8 | 2,583 | 3 | 3 | [
"MIT"
] | permissive | use std::borrow::Borrow;
use std::collections::HashMap;
use std::fs::File;
use std::hash::Hash;
use std::io::{BufRead, BufReader, Write};
use std::path::Path;
pub struct Usage(HashMap<String, usize>);
impl Usage {
pub fn from_path(path: impl AsRef<Path>) -> Self {
let usage = crate::desktop::xdg_dirs()
... | true |
c3837bf90f14b1c57ff8c4f6a56041274bef63f1 | Rust | nlicitra/best-friend | /src/utils.rs | UTF-8 | 1,410 | 3.171875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[allow(dead_code)]
pub fn set_panic_hook() {
// When the `console_error_panic_hook` feature is enabled, we can call the
// `set_panic_hook` function at least once during initialization, and then
// we will get better error messages if our code ever panics.
//
// For more details see
// https://... | true |
f5724096bc7f1e253812c42ae855edec5d0e1b16 | Rust | dhconnelly/advent-of-code-2019 | /rs/day4/src/main.rs | UTF-8 | 1,511 | 3.09375 | 3 | [
"MIT"
] | permissive | use std::env;
use std::error::Error;
use std::fs;
fn valid1(mut x: i32) -> bool {
let mut prev = x % 10;
let mut chain = 1;
let mut two_chain = false;
x /= 10;
while x > 0 {
let y = x % 10;
if y > prev {
return false;
}
if y == prev {
chain +=... | true |
0826d007207764da0e8be69d9cad02987b662c98 | Rust | xychelsea/cglue | /cglue/src/tests/generics/associated.rs | UTF-8 | 3,497 | 2.78125 | 3 | [
"MIT"
] | permissive | use super::super::simple::structs::*;
use super::super::simple::trait_defs::*;
use super::groups::*;
use super::param::*;
use cglue_macro::*;
use core::ffi::c_void;
#[cglue_trait]
pub trait AssociatedReturn {
#[wrap_with(*const c_void)]
#[return_wrap(|ret| Box::leak(Box::new(ret)) as *mut _ as *const c_void)]
... | true |
081dfde6b4400b5aae807e215cc180157d0d19c6 | Rust | kroeckx/ruma | /crates/ruma-client-api/src/r0/account/get_username_availability.rs | UTF-8 | 1,142 | 3.140625 | 3 | [
"MIT"
] | permissive | //! [GET /_matrix/client/r0/register/available](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-register-available)
use ruma_api::ruma_api;
ruma_api! {
metadata: {
description: "Checks to see if a username is available, and valid, for the server.",
method: GET,
name:... | true |
60b7d06bc9353cd54f310aa34ef9c4de9fcb6d3e | Rust | gwierzchowski/cryptoexch | /src/zonda/trading_orderbook/csv.rs | UTF-8 | 2,364 | 2.828125 | 3 | [
"MIT"
] | permissive | /*!
* Implementation of CSV output format of trading/orderbook" API from "Zonda" module.
*/
use std::any::Any;
use anyhow::Result;
use async_trait::async_trait;
use serde::Serialize;
/// Record of output object.
/// Output object depends on output format and is defined in respective sub-module.
#[derive(Serialize... | true |
9aa22aad4e630a85a5364dd8de6d2941fcb232fc | Rust | GarettCooper/gc_nes_emulator | /gc_nes_core/src/cartridge/mapper.rs | UTF-8 | 19,564 | 3.03125 | 3 | [
"MIT"
] | permissive | //! The mapper module contains implementation code for the various
//! types of mapping circuits that were present in NES cartridges.
//!
//! At present only iNES mappers 000 through 004 are supported.
use super::*;
/// Returns a boxed mapper based on the mapper_id argument
pub(super) fn get_mapper(mapper_id: u16, su... | true |
b5ac66b03f39c3c91a9f13860a56ef1758a7d519 | Rust | dylanleclair/atlas | /src/main.rs | UTF-8 | 3,363 | 3.1875 | 3 | [] | no_license | use std::collections::HashMap; // used to parse command line args
use std::env; // used to parse command line args
use image::io::Reader as ImageReader; // imported to read images while binding them to atlas
use image::{GenericImage}; // imported to support in textures
use std::path::Path;
use std::fs;
const DEFAULT_... | true |
5716fab22cafe29f725cc555830f9a5f45b8b2a4 | Rust | etrombly/bluepill | /src/clock.rs | UTF-8 | 821 | 2.609375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Set Clock Speed
use stm32f103xx::{Rcc, Flash};
/// Initializes SYSCLK to 72Mhz
pub fn init(rcc: &Rcc, flash: &Flash) {
// enable external clock
rcc.cr.modify(|_,w| w.hseon().enabled());
while rcc.cr.read().hserdy().is_notready() {}
// configure pll to external clock * 9
rcc.cfgr.modify(|_,w| ... | true |
b95968885b3bdfe485fd6fa4c420b735fa7f7f84 | Rust | lRiaXl/public | /rust/tests/roman_numbers_test/src/main.rs | UTF-8 | 1,623 | 3.828125 | 4 | [] | no_license | // # Instructions
// Implement the From<u32> Trait to create a roman number from a u32
// the roman number should be in subtractive notation (the common way to write roman
// number I, II, II, IV, V, VI, VII, VIII, IX, X ...)
// For this start by defining the digits as `RomanDigit` with the values
// I, V, X, L, C, D,... | true |
f20dbd220a37a9a599287c9f72cd39861fbd4a0f | Rust | sybila/biodivine-lib-std | /src/impl_id_state.rs | UTF-8 | 1,168 | 3.40625 | 3 | [
"MIT"
] | permissive | use super::{IdState, State};
use std::fmt::{Display, Error, Formatter};
impl State for IdState {}
impl From<usize> for IdState {
fn from(val: usize) -> Self {
return IdState(val);
}
}
impl Into<usize> for IdState {
fn into(self) -> usize {
return self.0;
}
}
impl Display for IdState ... | true |
082d63ffb45209e931c7fda49b68fddcdcddd8ce | Rust | sinclair20/cracking_the_coding_interview_6th_edition_rust | /src/c7_q2.rs | UTF-8 | 3,557 | 3.84375 | 4 | [
"Apache-2.0"
] | permissive | // Call Center: Imagine you have a call center with three levels of employees: respondent, manager,
// and director. An incoming telephone call must be first allocated to a respondent who is free. If the
// respondent can't handle the call, he or she must escalate the call to a manager. If the manager is not
// free or... | true |
fabfca92c20671bdcffffd1aea926fb39c08ab5c | Rust | stefan-k/finitediff | /src/pert.rs | UTF-8 | 1,116 | 2.625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2018-2020 argmin developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://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 except according... | true |
0a469f4b2db05dff4ba8abc0b9f7c7bb533fcc20 | Rust | mchesser/pchip | /src/dlx/codegen.rs | UTF-8 | 43,735 | 2.640625 | 3 | [
"MIT"
] | permissive | use std::collections::{
hash_map::Entry::{Occupied, Vacant},
HashMap,
};
use crate::{
ast,
dlx::asm::{self, Instruction, LabelId, RegId},
dlx::types::{self, Type, TypeTable},
error::{InputSpan, Logger},
};
use self::{Ident::*, IdentId::*, Location::*};
const UNIT_TYPE: Type = types::Normal(0)... | true |
12553702c11784035e1fb99dfb556bdae583bec1 | Rust | shayneofficer/Advent-of-Code-2019 | /04-secure-container/01.rs | UTF-8 | 934 | 3.75 | 4 | [] | no_license |
fn main() {
let input_max: u32 = 905157;
let input_min: u32 = 372037;
let mut total_possible_passwords: u32 = 0;
for i in input_min..input_max {
let sequence: Vec<u32> = number_to_vec(i);
if is_non_decreasing(&sequence) && contains_pair(&sequence) {
total_possible_password... | true |
d21da06ef7dd04de0b1e2c4c6eab9184b1e74ac1 | Rust | Restioson/spinny | /src/lib.rs | UTF-8 | 3,595 | 2.71875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // MIT/Apache2 License
//! Implementation of a basic spin-based RwLock
#![no_std]
#![warn(clippy::pedantic)]
use core::sync::atomic::{spin_loop_hint, AtomicUsize, Ordering};
use lock_api::{GuardSend, RawRwLock, RawRwLockDowngrade, RawRwLockUpgrade, RwLock as LARwLock, RwLockReadGuard as LARwLockReadGuard, RwLockWrit... | true |
36968cdcaaa3c033e934e588b1492c6481799f8d | Rust | cjhopman/starlark-rust | /starlark/src/values/mutability.rs | UTF-8 | 9,775 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2018 The Starlark in Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable la... | true |
425bb0d4c9eb93e77abd5659a9f5045b7951d283 | Rust | 18B01A05D8/ElitePrograms | /golf.rs | UTF-8 | 871 | 3.359375 | 3 | [] | no_license | use std::collections::HashMap;
fn main(){
let golf_scores: HashMap<&str, i32> = [("albatross", -3),("eagle", -2),("birdie", -1),("par",0),("bogey",1),("double-bogey",2),("triple-bogey",3)].iter().cloned().collect();
let input_list = ["eagle" , "bogey" , "par" , "bogey" , "double-bogey" , "birdie" ,"bogey" ,"pa... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.