file_name
large_stringlengths
4
69
prefix
large_stringlengths
0
26.7k
suffix
large_stringlengths
0
24.8k
middle
large_stringlengths
0
2.12k
fim_type
large_stringclasses
4 values
weblog.rs
use std::fmt; // Define a weblog struct #[derive(Debug)] pub struct Weblog { pub ip: String, pub date: String, pub req: String, pub code: i32, pub size: i32, pub referer: String, pub agent: String, } impl Weblog { pub fn new(ip: String, date: String, req: String, code: i32, size: i32, ...
} impl fmt::Display for Weblog { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "({}, {}, {}, {}, {}, {}, {})", self.ip, self.date, self.req, self.code, self.size, self.referer, self.agent) } }
fn eq(&self, other: &Self) -> bool { self.ip == other.ip && self.date == other.date }
random_line_split
mir-typeck-normalize-fn-sig.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<'x> { foo: for<'y> fn(x: &'x u32, y: &'y u32) -> <u32 as Foo<'x>>::Value, } fn foo<'y, 'x: 'x>(x: &'x u32, y: &'y u32) -> <u32 as Foo<'x>>::Value { *x as f64 } fn main() { Providers { foo }; }
Providers
identifier_name
mir-typeck-normalize-fn-sig.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ Providers { foo }; }
identifier_body
mir-typeck-normalize-fn-sig.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// normalizing the signature afterwards. As a result, we sometimes got // errors around the `<u32 as Foo<'x>>::Value`, which can be // normalized to `f64`. #![allow(dead_code)] trait Foo<'x> { type Value; } impl<'x> Foo<'x> for u32 { type Value = f64; } struct Providers<'x> { foo: for<'y> fn(x: &'x u32,...
// which involves extracting its signature, but we were not
random_line_split
lib.rs
//! Parallel mutation of vectors via non-overlapping slices. #![cfg_attr(feature = "bench", feature(test, step_by))] use std::fmt::{Formatter, Debug}; use std::fmt::Error as FmtError; use std::sync::{Arc, Condvar, Mutex}; use std::mem; use std::ops; /// Our inner `Vec` container. struct VecBox<T> { slice_count: u...
() { // Test a reasonable number of primes to make sure the function actually works for &i in &[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37] { assert!(is_prime(i)); } for i in (4..40).step_by(2) { assert!(!is_prime(i)); } } }
test_is_prime
identifier_name
lib.rs
//! Parallel mutation of vectors via non-overlapping slices. #![cfg_attr(feature = "bench", feature(test, step_by))] use std::fmt::{Formatter, Debug}; use std::fmt::Error as FmtError; use std::sync::{Arc, Condvar, Mutex}; use std::mem; use std::ops; /// Our inner `Vec` container. struct VecBox<T> { slice_count: u...
let slice = &parent[start..end]; start += slice_len; slice as *const [T] as *mut [T] }).collect() } /// A slice of `ParVec` that can be sent to another task for processing. /// Automatically releases the slice on drop. pub struct ParSlice<T: Send> { inner: Arc<ParVecInner<T>>, data...
(1 .. slice_count + 1).rev().map(|curr| { let slice_len = (len - start) / curr; let end = cmp::min(start + slice_len, len);
random_line_split
lib.rs
//! Parallel mutation of vectors via non-overlapping slices. #![cfg_attr(feature = "bench", feature(test, step_by))] use std::fmt::{Formatter, Debug}; use std::fmt::Error as FmtError; use std::sync::{Arc, Condvar, Mutex}; use std::mem; use std::ops; /// Our inner `Vec` container. struct VecBox<T> { slice_count: u...
#[bench] fn par_prime_factors_1000(b: &mut Bencher) { let mut rng = thread_rng(); let pool = ThreadPool::new(TEST_SLICES); b.iter(|| { let mut vec: Vec<(u32, Vec<u32>)> = (1.. TEST_MAX) .map(|x| (x, Vec::new())).collect(); // Shuffle so each thr...
{ let vec: Vec<u32> = (1 .. TEST_MAX).collect(); b.iter(|| { let _: Vec<(u32, Vec<u32>)> = vec.iter() .map(|&x| (x, get_prime_factors(x))) .collect(); }); }
identifier_body
rpc.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
, apis: ApiSet::IpcContext, } } } #[derive(Debug, Clone, PartialEq)] pub struct WsConfiguration { pub enabled: bool, pub interface: String, pub port: u16, pub apis: ApiSet, pub origins: Option<Vec<String>>, pub hosts: Option<Vec<String>>, pub signer_path: PathBuf, pub support_token_api: bool, pub ui_add...
{ let data_dir = ::dir::default_data_path(); parity_ipc_path(&data_dir, "$BASE/jsonrpc.ipc", 0) }
conditional_block
rpc.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
<D: rpc_apis::Dependencies> { pub apis: Arc<D>, pub remote: TokioRemote, pub stats: Arc<RpcStats>, pub pool: Option<CpuPool>, } pub fn new_ws<D: rpc_apis::Dependencies>( conf: WsConfiguration, deps: &Dependencies<D>, ) -> Result<Option<WsServer>, String> { if!conf.enabled { return Ok(None); } let domain = ...
Dependencies
identifier_name
rpc.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
} fn address(enabled: bool, bind_iface: &str, bind_port: u16, hosts: &Option<Vec<String>>) -> Option<rpc::Host> { if!enabled { return None; } match *hosts { Some(ref hosts) if!hosts.is_empty() => Some(hosts[0].clone().into()), _ => Some(format!("{}:{}", bind_iface, bind_port).into()), } } pub struct Depen...
{ address(self.enabled, &self.interface, self.port, &self.hosts) }
identifier_body
rpc.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
} } pub fn new_ipc<D: rpc_apis::Dependencies>( conf: IpcConfiguration, dependencies: &Dependencies<D> ) -> Result<Option<IpcServer>, String> { if!conf.enabled { return Ok(None); } let handler = setup_apis(conf.apis, dependencies); let remote = dependencies.remote.clone(); let path = PathBuf::from(&conf.sock...
Err(ref err) if err.kind() == io::ErrorKind::AddrInUse => Err( format!("{} address {} is already in use, make sure that another instance of an Ethereum client is not running or change the address using the --{}-port and --{}-interface options.", id, url, options, options) ), Err(e) => Err(format!("{} error: {:...
random_line_split
buffer.rs
use crate::parsing::ParsingContext; use amq_protocol::frame::{BackToTheBuffer, GenError, GenResult, WriteContext}; use futures_io::{AsyncRead, AsyncWrite}; use std::{ cmp, io::{self, IoSlice, IoSliceMut}, pin::Pin, task::{Context, Poll}, }; #[derive(Debug, PartialEq, Clone)] pub(crate) struct Buffer { ...
else if self.end >= self.position { let (start, end) = self.memory.split_at_mut(self.end); reader.poll_read_vectored( cx, &mut [ IoSliceMut::new(&mut *end), IoSliceMut::new(&mut start[..self.position]), ][.....
{ Poll::Ready(Ok(0)) }
conditional_block
buffer.rs
use crate::parsing::ParsingContext; use amq_protocol::frame::{BackToTheBuffer, GenError, GenResult, WriteContext}; use futures_io::{AsyncRead, AsyncWrite}; use std::{ cmp, io::{self, IoSlice, IoSliceMut}, pin::Pin, task::{Context, Poll}, }; #[derive(Debug, PartialEq, Clone)] pub(crate) struct Buffer { ...
pub(crate) fn rollback(&mut self, checkpoint: Checkpoint) { if checkpoint.end == self.end { return; } if checkpoint.backwards { if self.end > checkpoint.end { self.available_data -= self.end - checkpoint.end; } else { self...
{ Checkpoint { end: self.end, backwards: true, } }
identifier_body
buffer.rs
use crate::parsing::ParsingContext; use amq_protocol::frame::{BackToTheBuffer, GenError, GenResult, WriteContext}; use futures_io::{AsyncRead, AsyncWrite}; use std::{ cmp, io::{self, IoSlice, IoSliceMut}, pin::Pin, task::{Context, Poll}, }; #[derive(Debug, PartialEq, Clone)] pub(crate) struct Buffer { ...
(&mut self) -> io::Result<()> { Ok(()) } } impl BackToTheBuffer for &mut Buffer { fn reserve_write_use< Tmp, Gen: Fn(WriteContext<Self>) -> Result<(WriteContext<Self>, Tmp), GenError>, Before: Fn(WriteContext<Self>, Tmp) -> GenResult<Self>, >( s: WriteContext<Self>, ...
flush
identifier_name
buffer.rs
use crate::parsing::ParsingContext; use amq_protocol::frame::{BackToTheBuffer, GenError, GenResult, WriteContext}; use futures_io::{AsyncRead, AsyncWrite}; use std::{ cmp, io::{self, IoSlice, IoSliceMut}, pin::Pin, task::{Context, Poll},
pub(crate) struct Buffer { memory: Vec<u8>, capacity: usize, position: usize, end: usize, available_data: usize, } pub(crate) struct Checkpoint { end: usize, backwards: bool, } impl Buffer { pub(crate) fn with_capacity(capacity: usize) -> Buffer { Buffer { memory: v...
}; #[derive(Debug, PartialEq, Clone)]
random_line_split
canvas_msg.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use canvas_paint_task::{FillOrStrokeStyle, LineCapStyle, LineJoinStyle, CompositionOrBlending}; use geom::matrix2d...
{ Canvas2d(Canvas2dMsg), Common(CanvasCommonMsg), WebGL(CanvasWebGLMsg), } #[derive(Clone)] pub enum Canvas2dMsg { Arc(Point2D<f32>, f32, f32, f32, bool), ArcTo(Point2D<f32>, Point2D<f32>, f32), DrawImage(Vec<u8>, Size2D<f64>, Rect<f64>, Rect<f64>, bool), DrawImageSelf(Size2D<f64>, Rect<f6...
CanvasMsg
identifier_name
canvas_msg.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use canvas_paint_task::{FillOrStrokeStyle, LineCapStyle, LineJoinStyle, CompositionOrBlending}; use geom::matrix2d...
LineTo(Point2D<f32>), MoveTo(Point2D<f32>), PutImageData(Vec<u8>, Rect<f64>, Option<Rect<f64>>), QuadraticCurveTo(Point2D<f32>, Point2D<f32>), Rect(Rect<f32>), RestoreContext, SaveContext, StrokeRect(Rect<f32>), Stroke, SetFillStyle(FillOrStrokeStyle), SetStrokeStyle(FillOrSt...
Clip, ClosePath, Fill, FillRect(Rect<f32>), GetImageData(Rect<f64>, Size2D<f64>, Sender<Vec<u8>>),
random_line_split
runner.rs
// Copyright (C) 2019, Cloudflare, Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright notice, // this list...
// Generate outgoing QUIC packets and send them on the UDP socket, until // quiche reports that there are no more packets to be sent. loop { let (write, send_info) = match conn.send(&mut out) { Ok(v) => v, Err(quiche::Error::Done) => { ...
}, } } }
random_line_split
runner.rs
// Copyright (C) 2019, Cloudflare, Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright notice, // this list...
{ hdrs.iter() .map(|h| { ( String::from_utf8(h.name().into()).unwrap(), String::from_utf8(h.value().into()).unwrap(), ) }) .collect() }
identifier_body
runner.rs
// Copyright (C) 2019, Cloudflare, Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright notice, // this list...
( test: &mut crate::Http3Test, peer_addr: std::net::SocketAddr, verify_peer: bool, idle_timeout: u64, max_data: u64, early_data: bool, session_file: Option<String>, ) -> Result<(), Http3TestError> { const MAX_DATAGRAM_SIZE: usize = 1350; let mut buf = [0; 65535]; let mut out = [0; MAX_DATAGRAM_...
run
identifier_name
fasta.rs
// Copyright 2014-2016 Johannes Köster, Christopher Schröder. // Licensed under the MIT license (http://opensource.org/licenses/MIT) // This file may not be copied, modified, or distributed // except according to those terms. //! FASTA format reading and writing. //! //! # Example //! //! ``` //! use std::io; //! use...
CCCC"; const FAI_FILE_NO_TRAILING_LF: &'static [u8] = b"id\t16\t9\t12\t13"; const WRITE_FASTA_FILE: &'static [u8] = b">id desc ACCGTAGGCTGA >id2 ATTGTTGTTTTA "; #[test] fn test_reader() { let reader = Reader::new(FASTA_FILE); let ids = [Some("id"), Some("id2")]; let descs = [S...
const FASTA_FILE_NO_TRAILING_LF : &'static [u8] = b">id desc GTAGGCTGAAAA
random_line_split
fasta.rs
// Copyright 2014-2016 Johannes Köster, Christopher Schröder. // Licensed under the MIT license (http://opensource.org/licenses/MIT) // This file may not be copied, modified, or distributed // except according to those terms. //! FASTA format reading and writing. //! //! # Example //! //! ``` //! use std::io; //! use...
asta: R, index: Index) -> Self { IndexedReader { reader: io::BufReader::new(fasta), index: index, } } /// For a given seqname, read the whole sequence into the given vector. pub fn read_all(&mut self, seqname: &str, seq: &mut Text) -> io::Result<()> { match s...
th_index(f
identifier_name
fasta.rs
// Copyright 2014-2016 Johannes Köster, Christopher Schröder. // Licensed under the MIT license (http://opensource.org/licenses/MIT) // This file may not be copied, modified, or distributed // except according to those terms. //! FASTA format reading and writing. //! //! # Example //! //! ``` //! use std::io; //! use...
/// Return the id of the record. pub fn id(&self) -> Option<&str> { self.header[1..].trim_right().splitn(2,'').next() } /// Return descriptions if present. pub fn desc(&self) -> Option<&str> { self.header[1..].trim_right().splitn(2,'').skip(1).next() } /// Return the sequen...
if self.id().is_none() { return Err("Expecting id for FastQ record."); } if !self.seq.is_ascii() { return Err("Non-ascii character found in sequence."); } Ok(()) }
identifier_body
one-use-in-struct.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
data: &'f u32 } enum Bar<'f> { Data(&'f u32) } trait Baz<'f> { } fn main() { }
#![allow(dead_code)] #![allow(unused_variables)] struct Foo<'f> {
random_line_split
one-use-in-struct.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { }
main
identifier_name
range_set.rs
#![allow(dead_code)] //! A set library to aid character set manipulation. //! //! `range_set` aims to make it easier to handle set manipulation for characters //! over ranges. For example, a unicode library may expose character ranges such //! as `('0', '9')` as a sequence of digits. If I was already later state I wou...
} // Insert value only when it's not a subset. if!subset { ret.insert(Range(min_val, max_val)); } } *self = Set(ret); } pub fn is_empty(&self) -> bool { self.0.is_empty() } pub fn remove(&mut self, value: Range) { let mut ret = BTreeSet::new(); ...
{ ret.insert(Range(min, max)); }
conditional_block
range_set.rs
#![allow(dead_code)] //! A set library to aid character set manipulation. //! //! `range_set` aims to make it easier to handle set manipulation for characters //! over ranges. For example, a unicode library may expose character ranges such //! as `('0', '9')` as a sequence of digits. If I was already later state I wou...
() -> Self { Set(BTreeSet::new()) } pub fn insert(&mut self, value: Range) { let mut ret = BTreeSet::new(); // value is a complete subset of one of the other ranges. let mut subset = false; // Borrowing self blocks later operation. Add a new scope. { let Set(ref set) = *se...
new
identifier_name
range_set.rs
#![allow(dead_code)] //! A set library to aid character set manipulation. //! //! `range_set` aims to make it easier to handle set manipulation for characters //! over ranges. For example, a unicode library may expose character ranges such //! as `('0', '9')` as a sequence of digits. If I was already later state I wou...
// Intersection of `A` & `B` is `A - (A - B)`: 123 & 345 = 3. pub fn intersection(&self, value: &Self) -> Self { let diff = self.difference(value); self.difference(&diff) } // 123 - 345 = 12. pub fn difference(&self, value: &Self) -> Self { let mut ret = self.clone(); ...
{ let mut ret = self.clone(); // Loop over the btreeset of Range(char, char). for &x in &value.0 { ret.insert(x) } ret }
identifier_body
range_set.rs
#![allow(dead_code)] //! A set library to aid character set manipulation. //! //! `range_set` aims to make it easier to handle set manipulation for characters //! over ranges. For example, a unicode library may expose character ranges such //! as `('0', '9')` as a sequence of digits. If I was already later state I wou...
#[derive(Clone, Copy, Debug, PartialOrd, Ord, PartialEq, Eq)] pub struct Range(pub char, pub char); impl fmt::Display for Range { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "({}, {})", self.0, self.1) } } impl Range { fn contains(&self, c: char) -> bool { self.0 <= c...
use std::collections::BTreeSet; use std::fmt::{self, Display}; use parse::NextPrev;
random_line_split
dma.rs
use hardware::cpu; use hardware::cpu::MapperHolder; pub struct DmaController { running: bool, base: u16, cycles: usize, pub oam_ram: [u8; 160], } impl cpu::Handler for DmaController { fn read(&self, address: u16) -> u8 { match address { 0xFE00..=0xFE9F => self.oam_ram[address a...
} self.cycles += 1; } }
{ if !self.running { return; } match self.cycles { 0 => { // There's a 1 cycle wait after enabling DMA } 1..=160 => { let dma_step = self.cycles as u16 - 1; let from = self.base + dma_step; ...
identifier_body
dma.rs
use hardware::cpu; use hardware::cpu::MapperHolder; pub struct DmaController { running: bool, base: u16, cycles: usize, pub oam_ram: [u8; 160], } impl cpu::Handler for DmaController { fn
(&self, address: u16) -> u8 { match address { 0xFE00..=0xFE9F => self.oam_ram[address as usize - 0xFE00], // TODO: not sure what should happen here, so let's just crash 0xFF46 => panic!("Trying to read from DMA."), _ => unreachable!(), } } fn writ...
read
identifier_name
dma.rs
use hardware::cpu; use hardware::cpu::MapperHolder;
cycles: usize, pub oam_ram: [u8; 160], } impl cpu::Handler for DmaController { fn read(&self, address: u16) -> u8 { match address { 0xFE00..=0xFE9F => self.oam_ram[address as usize - 0xFE00], // TODO: not sure what should happen here, so let's just crash 0xFF46 =...
pub struct DmaController { running: bool, base: u16,
random_line_split
record-pat.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. enum t1 { a(int)...
// file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT.
random_line_split
record-pat.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} } pub fn main() { assert_eq!(m(c(T2 {x: a(10), y: 5}, 4u)), 10); assert_eq!(m(c(T2 {x: b(10u), y: 5}, 4u)), 19); }
{ return ((m + z) as int) + y; }
conditional_block
record-pat.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ assert_eq!(m(c(T2 {x: a(10), y: 5}, 4u)), 10); assert_eq!(m(c(T2 {x: b(10u), y: 5}, 4u)), 19); }
identifier_body
record-pat.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{x: t1, y: int} enum t3 { c(T2, uint), } fn m(input: t3) -> int { match input { c(T2 {x: a(m),..}, _) => { return m; } c(T2 {x: b(m), y: y}, z) => { return ((m + z) as int) + y; } } } pub fn main() { assert_eq!(m(c(T2 {x: a(10), y: 5}, 4u)), 10); assert_eq!(m(c(T2 {x: b(10u), y: 5}, 4u)),...
T2
identifier_name
setup.rs
use docopt_args::DocoptArgs; use ProtonConfig; use std::io::{self, BufRead, stdout, StdinLock, Write}; pub fn initial_setup(_args: DocoptArgs) { configure(ProtonConfig::default_config()) } pub fn configure(old_config: ProtonConfig)
} // Gets a config value from user input. Uses default value if nothing is provided fn get_config_value<'a>(prompt: &'a str, default: String, handle: &'a mut StdinLock) -> String { print!("{} [{}]: ", prompt, default); let _ = stdout().flush(); let mut value = String::new(); handle.read_line(&mut valu...
{ // Setup IO stuff let stdin = io::stdin(); let mut handle = stdin.lock(); // Get config values let key_path = get_config_value("key_path", old_config.key, &mut handle); let vixen_folder = get_config_value("vixen_folder", old_config.vixen_folder, &mut handle); let vixen_converter_py = get_...
identifier_body
setup.rs
use docopt_args::DocoptArgs; use ProtonConfig; use std::io::{self, BufRead, stdout, StdinLock, Write}; pub fn initial_setup(_args: DocoptArgs) { configure(ProtonConfig::default_config()) } pub fn configure(old_config: ProtonConfig) { // Setup IO stuff let stdin = io::stdin(); let mut handle = stdin.l...
// Get config values let key_path = get_config_value("key_path", old_config.key, &mut handle); let vixen_folder = get_config_value("vixen_folder", old_config.vixen_folder, &mut handle); let vixen_converter_py = get_config_value("vixen_converter_py", old_config.vixen_converter_py, &mut handle); let d...
random_line_split
setup.rs
use docopt_args::DocoptArgs; use ProtonConfig; use std::io::{self, BufRead, stdout, StdinLock, Write}; pub fn initial_setup(_args: DocoptArgs) { configure(ProtonConfig::default_config()) } pub fn configure(old_config: ProtonConfig) { // Setup IO stuff let stdin = io::stdin(); let mut handle = stdin.l...
<'a>(prompt: &'a str, default: String, handle: &'a mut StdinLock) -> String { print!("{} [{}]: ", prompt, default); let _ = stdout().flush(); let mut value = String::new(); handle.read_line(&mut value).expect("Failed to read line of user input"); value = value.trim().to_string(); if value == "" ...
get_config_value
identifier_name
setup.rs
use docopt_args::DocoptArgs; use ProtonConfig; use std::io::{self, BufRead, stdout, StdinLock, Write}; pub fn initial_setup(_args: DocoptArgs) { configure(ProtonConfig::default_config()) } pub fn configure(old_config: ProtonConfig) { // Setup IO stuff let stdin = io::stdin(); let mut handle = stdin.l...
value }
{ value = default; }
conditional_block
issue-36116.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn main() {}
fn f() { let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>); //~ WARN unnecessary path disambiguator let g: Foo::<i32> = Foo { _a: 42 }; //~ WARN unnecessary path disambiguator m!(S::<u8>); // OK, no warning
random_line_split
issue-36116.rs
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>); //~ WARN unnecessary path disambiguator let g: Foo::<i32> = Foo { _a: 42 }; //~ WARN unnecessary path disambiguator m!(S::<u8>); // OK, no warning } fn main() {}
f
identifier_name
slice-panic-2.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
; static mut DTOR_COUNT: isize = 0; impl Drop for Foo { fn drop(&mut self) { unsafe { DTOR_COUNT += 1; } } } fn bar() -> usize { panic!(); } fn foo() { let x: &[_] = &[Foo, Foo]; &x[3..bar()]; } fn main() { let _ = thread::spawn(move|| foo()).join(); unsafe { assert!(DTOR_COUNT == 2); } }
Foo
identifier_name
slice-panic-2.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
}
random_line_split
slice-panic-2.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn foo() { let x: &[_] = &[Foo, Foo]; &x[3..bar()]; } fn main() { let _ = thread::spawn(move|| foo()).join(); unsafe { assert!(DTOR_COUNT == 2); } }
{ panic!(); }
identifier_body
issue-30530.rs
// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ Default, #[allow(dead_code)] Custom(*mut Box<dyn Fn()>), } fn main() { #[allow(unused_must_use)] { take(Handler::Default, Box::new(main)); } } #[inline(never)] pub fn take(h: Handler, f: Box<dyn Fn()>) -> Box<dyn Fn()> { unsafe { match h { Handler::Custom(ptr) =>...
Handler
identifier_name
issue-30530.rs
// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
Custom(*mut Box<dyn Fn()>), } fn main() { #[allow(unused_must_use)] { take(Handler::Default, Box::new(main)); } } #[inline(never)] pub fn take(h: Handler, f: Box<dyn Fn()>) -> Box<dyn Fn()> { unsafe { match h { Handler::Custom(ptr) => *Box::from_raw(ptr), Handle...
#[allow(dead_code)]
random_line_split
issue-30530.rs
// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ unsafe { match h { Handler::Custom(ptr) => *Box::from_raw(ptr), Handler::Default => f, } } }
identifier_body
issue-7563.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn do_nothing(&self); } struct A { a: int } struct B<'a> { b: int, pa: &'a A } impl IDummy for A { fn do_nothing(&self) { println!("A::do_nothing() is called"); } } impl<'a> B<'a> { fn get_pa(&self) -> &'a IDummy { self.pa as &'a IDummy } } pub fn main() { let sa = A ...
extern crate debug; trait IDummy {
random_line_split
issue-7563.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<'a> { b: int, pa: &'a A } impl IDummy for A { fn do_nothing(&self) { println!("A::do_nothing() is called"); } } impl<'a> B<'a> { fn get_pa(&self) -> &'a IDummy { self.pa as &'a IDummy } } pub fn main() { let sa = A { a: 100 }; let sb = B { b: 200, pa: &sa }; prin...
B
identifier_name
cfg-macros-foo.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ assert!(bar!()) }
identifier_body
cfg-macros-foo.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
assert!(bar!()) }
} } pub fn main() {
random_line_split
cfg-macros-foo.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { assert!(bar!()) }
main
identifier_name
kindck-copy.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
trait Dummy { } struct MyStruct { x: isize, y: isize, } impl Copy for MyStruct {} struct MyNoncopyStruct { x: Box<char>, } fn test<'a,T,U:Copy>(_: &'a isize) { // lifetime pointers are ok... assert_copy::<&'static isize>(); assert_copy::<&'a isize>(); assert_copy::<&'a str>(); asse...
{ }
identifier_body
kindck-copy.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ x: isize, y: isize, } impl Copy for MyStruct {} struct MyNoncopyStruct { x: Box<char>, } fn test<'a,T,U:Copy>(_: &'a isize) { // lifetime pointers are ok... assert_copy::<&'static isize>(); assert_copy::<&'a isize>(); assert_copy::<&'a str>(); assert_copy::<&'a [isize]>(); //....
MyStruct
identifier_name
kindck-copy.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
// tuples are ok assert_copy::<(isize,isize)>(); // structs of POD are ok assert_copy::<MyStruct>(); // structs containing non-POD are not ok assert_copy::<MyNoncopyStruct>(); //~ ERROR `core::marker::Copy` is not implemented // ref counted types are not ok assert_copy::<Rc<isize>>();...
assert_copy::<bool>(); assert_copy::<()>();
random_line_split
helper_thread.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn shutdown(&'static self) { unsafe { // Shut down, but make sure this is done inside our lock to ensure // that we'll always receive the exit signal when the thread // returns. let guard = self.lock.lock(); // Close the channel by destroying it...
{ unsafe { let _guard = self.lock.lock(); // Must send and *then* signal to ensure that the child receives the // message. Otherwise it could wake up and go to sleep before we // send the message. assert!(!self.chan.get().is_null()); (**se...
identifier_body
helper_thread.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
<M> { /// Internal lock which protects the remaining fields pub lock: StaticNativeMutex, // You'll notice that the remaining fields are UnsafeCell<T>, and this is // because all helper thread operations are done through &self, but we need // these to be mutable (once `lock` is held). /// Lazil...
Helper
identifier_name
helper_thread.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} } /// Sends a message to a spawned worker thread. /// /// This is only valid if the worker thread has previously booted pub fn send(&'static self, msg: M) { unsafe { let _guard = self.lock.lock(); // Must send and *then* signal to ensure that the child re...
{ let (tx, rx) = channel(); *self.chan.get() = mem::transmute(box tx); let (receive, send) = helper_signal::new(); *self.signal.get() = send as uint; let t = f(); task::spawn(proc() { bookkeeping::decrem...
conditional_block
helper_thread.rs
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
//! The timer thread is lazily initialized, and it's shut down via the //! `shutdown` function provided. It must be maintained as an invariant that //! `shutdown` is only called when the entire program is finished. No new timers //! can be created in the future and there must be no active timers at that //! time. use ...
//!
random_line_split
ipc.rs
//! Alacritty socket IPC. use std::ffi::OsStr; use std::io::{BufRead, BufReader, Error as IoError, ErrorKind, Result as IoResult, Write}; use std::os::unix::net::{UnixListener, UnixStream}; use std::path::PathBuf; use std::{env, fs, process}; use glutin::event_loop::EventLoopProxy; use log::warn; use alacritty_termi...
() -> PathBuf { env::temp_dir() } /// Find the IPC socket path. fn find_socket(socket_path: Option<PathBuf>) -> IoResult<UnixStream> { // Handle --socket CLI override. if let Some(socket_path) = socket_path { // Ensure we inform the user about an invalid path. return UnixStream::connect(&so...
socket_dir
identifier_name
ipc.rs
//! Alacritty socket IPC. use std::ffi::OsStr; use std::io::{BufRead, BufReader, Error as IoError, ErrorKind, Result as IoResult, Write}; use std::os::unix::net::{UnixListener, UnixStream}; use std::path::PathBuf; use std::{env, fs, process}; use glutin::event_loop::EventLoopProxy; use log::warn; use alacritty_termi...
warn!("Unable to create socket: {:?}", err); return None; }, }; // Spawn a thread to listen on the IPC socket. thread::spawn_named("socket listener", move || { let mut data = String::new(); for stream in listener.incoming().filter_map(Result::ok) { ...
env::set_var(ALACRITTY_SOCKET_ENV, socket_path.as_os_str()); let listener = match UnixListener::bind(&socket_path) { Ok(listener) => listener, Err(err) => {
random_line_split
ipc.rs
//! Alacritty socket IPC. use std::ffi::OsStr; use std::io::{BufRead, BufReader, Error as IoError, ErrorKind, Result as IoResult, Write}; use std::os::unix::net::{UnixListener, UnixStream}; use std::path::PathBuf; use std::{env, fs, process}; use glutin::event_loop::EventLoopProxy; use log::warn; use alacritty_termi...
/// File prefix matching all available sockets. #[cfg(target_os = "macos")] fn socket_prefix() -> String { String::from("Alacritty") }
{ let display = env::var("WAYLAND_DISPLAY").or_else(|_| env::var("DISPLAY")).unwrap_or_default(); format!("Alacritty-{}", display) }
identifier_body
model.rs
use chrono::*; pub use location::GpsCoordinates; use irradiance; pub struct
<Tz: TimeZone> { pub coords: GpsCoordinates, pub date_time: DateTime<Tz>, } pub struct ModelOutput { pub day_of_year: u32, pub eot: f64, pub local_meridian_long: f64, pub time_correction_factor: f64, pub solar_time: f64, pub hour_angle: f64, pub declination_angle: f64, pub eleva...
ModelParams
identifier_name
model.rs
use chrono::*; pub use location::GpsCoordinates; use irradiance; pub struct ModelParams<Tz: TimeZone> { pub coords: GpsCoordinates, pub date_time: DateTime<Tz>, } pub struct ModelOutput { pub day_of_year: u32, pub eot: f64, pub local_meridian_long: f64, pub time_correction_factor: f64, pub...
hour_angle); let zenith_angle = irradiance::zenith_angle(elevation_angle); let air_mass = irradiance::air_mass(zenith_angle); let irradiance = irradiance::irradiance(air_mass); ModelOutput { day_of_year: day_of_year, eot: eot, ...
let ModelParams { coords, date_time } = params; let gmt_offset = date_time.offset().local_minus_utc(); let day_of_year = date_time.ordinal(); let eot = irradiance::equation_of_time(day_of_year); let local_meridian_long = irradiance::local_standard_meridian_longitude(gmt_...
identifier_body
model.rs
use chrono::*; pub use location::GpsCoordinates; use irradiance; pub struct ModelParams<Tz: TimeZone> { pub coords: GpsCoordinates, pub date_time: DateTime<Tz>, } pub struct ModelOutput { pub day_of_year: u32, pub eot: f64, pub local_meridian_long: f64, pub time_correction_factor: f64, pub...
zenith_angle: zenith_angle, air_mass: air_mass, irradiance: irradiance, } }
solar_time: solar_time, hour_angle: hour_angle, declination_angle: declination_angle, elevation_angle: elevation_angle,
random_line_split
link_style.rs
/// Determines the hyperlink style used in commit and issue links. Defaults to `LinksStyle::Github` /// /// # Example /// /// ```no_run /// # use clog::{LinkStyle, Clog}; /// let mut clog = Clog::new().unwrap(); /// clog.link_style(LinkStyle::Stash); /// ``` clog_enum!{ #[derive(Debug)] pub enum LinkStyle { ...
} } /// Gets a hyperlink url to a commit in the specified format. /// /// # Example /// ```no_run /// # use clog::{LinkStyle, Clog}; /// let link = LinkStyle::Github; /// let commit = link.commit_link("123abc891234567890abcdefabc4567898724", "https://github.com/thoughtram/clog")...
LinkStyle::Stash => format!("{}", issue.as_ref()), } }
random_line_split
link_style.rs
/// Determines the hyperlink style used in commit and issue links. Defaults to `LinksStyle::Github` /// /// # Example /// /// ```no_run /// # use clog::{LinkStyle, Clog}; /// let mut clog = Clog::new().unwrap(); /// clog.link_style(LinkStyle::Stash); /// ``` clog_enum!{ #[derive(Debug)] pub enum LinkStyle { ...
} } /// Gets a hyperlink url to a commit in the specified format. /// /// # Example /// ```no_run /// # use clog::{LinkStyle, Clog}; /// let link = LinkStyle::Github; /// let commit = link.commit_link("123abc891234567890abcdefabc4567898724", "https://github.com/thoughtram/clog"...
{ match *self { LinkStyle::Github => format!("{}/issues/{}", link, issue.as_ref()), LinkStyle::Gitlab => format!("{}/issues/{}", link, issue.as_ref()), LinkStyle::Stash => format!("{}", issue.as_ref()), } }
conditional_block
link_style.rs
/// Determines the hyperlink style used in commit and issue links. Defaults to `LinksStyle::Github` /// /// # Example /// /// ```no_run /// # use clog::{LinkStyle, Clog}; /// let mut clog = Clog::new().unwrap(); /// clog.link_style(LinkStyle::Stash); /// ``` clog_enum!{ #[derive(Debug)] pub enum LinkStyle { ...
/// Gets a hyperlink url to a commit in the specified format. /// /// # Example /// ```no_run /// # use clog::{LinkStyle, Clog}; /// let link = LinkStyle::Github; /// let commit = link.commit_link("123abc891234567890abcdefabc4567898724", "https://github.com/thoughtram/clog"); /// /...
{ match repo.as_ref() { "" => format!("{}", issue.as_ref()), link => { match *self { LinkStyle::Github => format!("{}/issues/{}", link, issue.as_ref()), LinkStyle::Gitlab => format!("{}/issues/{}", link, issue.as_ref()), ...
identifier_body
link_style.rs
/// Determines the hyperlink style used in commit and issue links. Defaults to `LinksStyle::Github` /// /// # Example /// /// ```no_run /// # use clog::{LinkStyle, Clog}; /// let mut clog = Clog::new().unwrap(); /// clog.link_style(LinkStyle::Stash); /// ``` clog_enum!{ #[derive(Debug)] pub enum LinkStyle { ...
<S: AsRef<str>>(&self, hash: S, repo: S) -> String { match repo.as_ref() { "" => format!("{}", &hash.as_ref()[0..8]), link => { match *self { LinkStyle::Github => format!("{}/commit/{}", link, hash.as_ref()), LinkStyle::Gitlab => fo...
commit_link
identifier_name
cfg.rs
macro_rules! cfg_feature { ( #![$meta:meta] $($item:item)* ) => { $( #[cfg($meta)] #[cfg_attr(docsrs, doc(cfg($meta)))] $item )* } } macro_rules! cfg_proto { ($($item:item)*) => { cfg_feature! { #![all( ...
} } }
random_line_split
lib.rs
/*! Tetris game engine. */ extern crate rand; mod bot; pub use self::bot::{Weights, PlayI, Play}; mod bag; pub use self::bag::{Bag, OfficialBag, BestBag, WorstBag}; mod input; pub use self::input::{Clock, Input}; mod pt; pub use self::pt::Point; mod piece; pub use self::piece::{Piece, Sprite}; mod rot; pub use s...
pub use self::srs::{SrsData, srs_cw, srs_ccw, srs_data_cw, srs_data_ccw}; mod player; pub use self::player::Player; mod well; pub use self::well::{Well, Line, ParseWellError, MAX_WIDTH, MAX_HEIGHT}; mod tile; pub use self::tile::{Tile, TileTy, TILE_BG0, TILE_BG1, TILE_BG2}; mod scene; pub use self::scene::{Scene}; ...
random_line_split
vga.rs
use core::mem; use core::ptr::Unique; use volatile::Volatile; use libd7::{syscall, PhysAddr, VirtAddr}; const SCREEN_HEIGHT: usize = 25; const SCREEN_WIDTH: usize = 80; const HARDWARE_BUFFER_ADDR: u64 = 0xb8000; const HARDWARE_BUFFER_SIZE: u64 = mem::size_of::<Buffer>() as u64; /// Should be free to use. Check plan....
.unwrap(); Unique::new_unchecked((VIRTUAL_ADDR + HARDWARE_BUFFER_ADDR).as_mut_ptr()) }
random_line_split
vga.rs
use core::mem; use core::ptr::Unique; use volatile::Volatile; use libd7::{syscall, PhysAddr, VirtAddr}; const SCREEN_HEIGHT: usize = 25; const SCREEN_WIDTH: usize = 80; const HARDWARE_BUFFER_ADDR: u64 = 0xb8000; const HARDWARE_BUFFER_SIZE: u64 = mem::size_of::<Buffer>() as u64; /// Should be free to use. Check plan....
(self) -> Color { unsafe { mem::transmute::<u8, Color>(self.0 & 0xf) } } pub fn background(self) -> Color { unsafe { mem::transmute::<u8, Color>((self.0 & 0xf0) >> 4) } } pub fn invert(self) -> CellColor { CellColor::new(self.background(), self.foreground()) } } /// Charac...
foreground
identifier_name
vga.rs
use core::mem; use core::ptr::Unique; use volatile::Volatile; use libd7::{syscall, PhysAddr, VirtAddr}; const SCREEN_HEIGHT: usize = 25; const SCREEN_WIDTH: usize = 80; const HARDWARE_BUFFER_ADDR: u64 = 0xb8000; const HARDWARE_BUFFER_SIZE: u64 = mem::size_of::<Buffer>() as u64; /// Should be free to use. Check plan....
{ syscall::mmap_physical( // Assumes 2MiB pages, so that 0xb8000 falls on the first page PhysAddr::new(0), VIRTUAL_ADDR, HARDWARE_BUFFER_SIZE, syscall::MemoryProtectionFlags::READ | syscall::MemoryProtectionFlags::WRITE, ) .unwrap(); Unique::new_unchecked((VIRTUAL...
identifier_body
build.rs
// Copyright 2015 Brendan Zabarauskas and the gl-rs developers // // 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 b...
}
random_line_split
build.rs
// Copyright 2015 Brendan Zabarauskas and the gl-rs developers // // 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 b...
() { let dest = env::var("OUT_DIR").unwrap(); let mut file = File::create(&Path::new(&dest).join("bindings.rs")).unwrap(); Registry::new(Api::WebGl2, Exts::ALL) .write_bindings(StdwebGenerator, &mut file) .unwrap(); }
main
identifier_name
build.rs
// Copyright 2015 Brendan Zabarauskas and the gl-rs developers // // 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 b...
{ let dest = env::var("OUT_DIR").unwrap(); let mut file = File::create(&Path::new(&dest).join("bindings.rs")).unwrap(); Registry::new(Api::WebGl2, Exts::ALL) .write_bindings(StdwebGenerator, &mut file) .unwrap(); }
identifier_body
rust.rs
/* mandelbrot 2015 Gabriel De Luca
*/ const NX: usize = 500; // number of points const NT: i32 = 100000; // number of timesteps fn main() { let mut x: [f64; NX] = [0.0_f64;NX]; // position along wave let mut y: [f64; NX] = [0.0_f64;NX]; // elevation of wave let mut v: [f64; NX] = [0.0_f64;NX]; // speed of wave (y direction) le...
MIT Licensed
random_line_split
rust.rs
/* mandelbrot 2015 Gabriel De Luca MIT Licensed */ const NX: usize = 500; // number of points const NT: i32 = 100000; // number of timesteps fn
() { let mut x: [f64; NX] = [0.0_f64;NX]; // position along wave let mut y: [f64; NX] = [0.0_f64;NX]; // elevation of wave let mut v: [f64; NX] = [0.0_f64;NX]; // speed of wave (y direction) let mut dvdt: [f64; NX] = [0.0_f64;NX]; // acceleration of wave (y direction) let mut dx: f64; ...
main
identifier_name
rust.rs
/* mandelbrot 2015 Gabriel De Luca MIT Licensed */ const NX: usize = 500; // number of points const NT: i32 = 100000; // number of timesteps fn main()
} x[(NX-1) as usize] = xmax; // define t spacing tmin = 0.0; tmax = 10.0; dt = (tmax-tmin)/((NT as f64)-1.0); // instantiate y, x, dvdt arrays // initialize arrays // y is a peak in the middle of the wave for i in 0..NX { y[i as usize] = ( -(x[i as usize] - (xmax - xmin) / 2.0) * (x[i as usize] - (xm...
{ let mut x: [f64; NX] = [0.0_f64;NX]; // position along wave let mut y: [f64; NX] = [0.0_f64;NX]; // elevation of wave let mut v: [f64; NX] = [0.0_f64;NX]; // speed of wave (y direction) let mut dvdt: [f64; NX] = [0.0_f64;NX]; // acceleration of wave (y direction) let mut dx: f64; ...
identifier_body
types.rs
// Copyright 2020 Google Inc. All Rights Reserved. // // 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...
{ Func = 0x70, Extern = 0x6F, } #[derive(Wasmbin, WasmbinCountable, Debug, Arbitrary, PartialEq, Eq, Hash, Clone, Visit)] pub struct TableType { pub elem_type: RefType, pub limits: Limits, } #[derive(Wasmbin, Debug, Arbitrary, PartialEq, Eq, Hash, Clone, Visit)] pub struct GlobalType { pub value_...
RefType
identifier_name
types.rs
// Copyright 2020 Google Inc. All Rights Reserved. // // 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...
Ok(()) } } #[wasmbin_discriminants] #[derive(Wasmbin)] #[repr(u8)] enum LimitsRepr { Min { min: u32 } = 0x00, MinMax { min: u32, max: u32 } = 0x01, } encode_decode_as!(Limits, { (Limits { min, max: None }) <=> (LimitsRepr::Min { min }), (Limits { min, max: Some(max) }) <=> (LimitsRepr::Mi...
{ write!(f, "={}", max)?; }
conditional_block
types.rs
// Copyright 2020 Google Inc. All Rights Reserved. // // 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...
use crate::visit::Visit; use crate::wasmbin_discriminants; use arbitrary::Arbitrary; use std::convert::TryFrom; use std::fmt::{self, Debug, Formatter}; const OP_CODE_EMPTY_BLOCK: u8 = 0x40; #[wasmbin_discriminants] #[derive(Wasmbin, WasmbinCountable, Debug, Arbitrary, PartialEq, Eq, Hash, Clone, Visit)] #[repr(u8)] p...
use crate::io::{Decode, DecodeError, DecodeWithDiscriminant, Encode, PathItem, Wasmbin};
random_line_split
mod.rs
use memory::PAGE_SIZE; // use memory::frame::Frame; use memory::alloc::FrameAlloc; pub const PRESENT: u64 = 1 << 0; pub const WRITABLE: u64 = 1 << 1; pub const USER_ACCESSIBLE: u64 = 1 << 2; pub const WRITE_THROUGH_CACHING: u64 = 1 << 3; pub const DISABLE_CACHE: u64 = 1 << 4; pub const ACCESSED: u64 = 1 << 5; pub cons...
/// Tests if next table exists and allocates a new one if not fn create_next_table<T: FrameAlloc>(allocator: &mut T, address: u64, index: isize) -> u64 { let mut entry = Page::get_table(address, index); if (entry & PRESENT)!= 0 { } else { let frame = allocator.alloc(); ...
}
random_line_split
mod.rs
use memory::PAGE_SIZE; // use memory::frame::Frame; use memory::alloc::FrameAlloc; pub const PRESENT: u64 = 1 << 0; pub const WRITABLE: u64 = 1 << 1; pub const USER_ACCESSIBLE: u64 = 1 << 2; pub const WRITE_THROUGH_CACHING: u64 = 1 << 3; pub const DISABLE_CACHE: u64 = 1 << 4; pub const ACCESSED: u64 = 1 << 5; pub cons...
else { let frame = allocator.alloc(); unsafe { *Page::get_table_mut(address, index) = (frame.unwrap().number * PAGE_SIZE) | PRESENT | WRITABLE; } ...
{ }
conditional_block
mod.rs
use memory::PAGE_SIZE; // use memory::frame::Frame; use memory::alloc::FrameAlloc; pub const PRESENT: u64 = 1 << 0; pub const WRITABLE: u64 = 1 << 1; pub const USER_ACCESSIBLE: u64 = 1 << 2; pub const WRITE_THROUGH_CACHING: u64 = 1 << 3; pub const DISABLE_CACHE: u64 = 1 << 4; pub const ACCESSED: u64 = 1 << 5; pub cons...
}
{ // Entry in P4 (P3 location) let p4_entry = Page::create_next_table(allocator, P4, self.p4_index() as isize); // Entry in P3 (P2 location) let p3_entry = Page::create_next_table(allocator, p4_entry & NO_FLAGS, ...
identifier_body
mod.rs
use memory::PAGE_SIZE; // use memory::frame::Frame; use memory::alloc::FrameAlloc; pub const PRESENT: u64 = 1 << 0; pub const WRITABLE: u64 = 1 << 1; pub const USER_ACCESSIBLE: u64 = 1 << 2; pub const WRITE_THROUGH_CACHING: u64 = 1 << 3; pub const DISABLE_CACHE: u64 = 1 << 4; pub const ACCESSED: u64 = 1 << 5; pub cons...
(physical_addr: u64, flags: u64, address: u64, index: isize) { unsafe { *Page::get_table_mut(address, index) = (physical_addr * PAGE_SIZE) | flags; } } /// Create page tables and allocate page /// /// This function walks through the page tables. If the next table is present,...
create_page
identifier_name
script_task.rs
constellation_chan.clone(), js_context.clone()); Rc::new(ScriptTask { page: RefCell::new(Rc::new(page)), image_cache_task: img_cache_task, resource_task: resource_task, port: port, chan: chan, const...
parent_page.children.deref().borrow_mut().push(Rc::new(new_page)); } /// Handles a timer that fired. fn handle_fire_timer_msg(&self, id: PipelineId, timer_id: TimerId) { let mut page = self.page.borrow_mut(); let page = page.find(id).expect("ScriptTask: received fire timer msg for ...
{ debug!("Script: new layout: {:?}", new_layout_info); let NewLayoutInfo { old_pipeline_id, new_pipeline_id, subpage_id, layout_chan } = new_layout_info; let mut page = self.page.borrow_mut(); let parent_page = page.find(old_pipeli...
identifier_body
script_task.rs
constellation_chan.clone(), js_context.clone()); Rc::new(ScriptTask { page: RefCell::new(Rc::new(page)), image_cache_task: img_cache_task, resource_task: resource_task, port: port, chan: chan, const...
(&self, _: PipelineId) { debug!("script task handling exit window msg"); // TODO(tkuehn): currently there is only one window, // so this can afford to be naive and just shut down the // compositor. In the future it'll need to be smarter. self.compositor.close(); } /// H...
handle_exit_window_msg
identifier_name
script_task.rs
mut(); let parent_page = page.find(old_pipeline_id).expect("ScriptTask: received a layout whose parent has a PipelineId which does not correspond to a pipeline in the script task's page tree. This is a bug."); let new_page = { let window_size = parent_page.window_size...
node.deref().set_hover_state(false); } } None => {}
random_line_split
geometry.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use euclid::{Rect, Point3D}; /* A naive port of "An Efficient and Robust Ray–Box Intersection Algorithm" from h...
if inv_direction.z < 0.0 { 1 } else { 0 }, ]; let parameters = [ Point3D::new(rect.origin.x, rect.origin.y, 0.0), Point3D::new(rect.origin.x + rect.size.width, rect.origin.y + rect.size.height, 0.0), ]...
0 },
conditional_block
geometry.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use euclid::{Rect, Point3D}; /* A naive port of "An Efficient and Robust Ray–Box Intersection Algorithm" from h...
ay_origin: Point3D<f32>, ray_end: Point3D<f32>, rect: Rect<f32>) -> bool { let mut dir = ray_end - ray_origin; let len = ((dir.x*dir.x) + (dir.y*dir.y) + (dir.z*dir.z)).sqrt(); dir.x = dir.x / len; dir.y = dir.y / len; dir.z = dir.z / len; le...
y_intersects_rect(r
identifier_name
geometry.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use euclid::{Rect, Point3D}; /* A naive port of "An Efficient and Robust Ray–Box Intersection Algorithm" from h...
} else { 0 }, ]; let parameters = [ Point3D::new(rect.origin.x, rect.origin.y, 0.0), Point3D::new(rect.origin.x + rect.size.width, rect.origin.y + rect.size.height, 0.0), ]; let mut tmin = (parameters[sign[0]].x - ra...
let mut dir = ray_end - ray_origin; let len = ((dir.x*dir.x) + (dir.y*dir.y) + (dir.z*dir.z)).sqrt(); dir.x = dir.x / len; dir.y = dir.y / len; dir.z = dir.z / len; let inv_direction = Point3D::new(1.0/dir.x, 1.0/dir.y, 1.0/dir.z); let sign = [ if inv_direction.x < 0.0 { ...
identifier_body
geometry.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use euclid::{Rect, Point3D}; /* A naive port of "An Efficient and Robust Ray–Box Intersection Algorithm" from h...
let t0 = 0.0; let t1 = len; (tmin < t1) && (tmax > t0) */ } /* pub fn circle_contains_rect(circle_center: &Point2D<f32>, radius: f32, rect: &Rect<f32>) -> bool { let dx = (circle_center.x - rect.origin.x).max(rect.origin.x + rect.size.width - circle_...
random_line_split
must_use.rs
use rustc_ast::ast::Attribute; use rustc_errors::Applicability; use rustc_hir::def_id::{DefIdSet, LocalDefId}; use rustc_hir::{self as hir, def::Res, intravisit, QPath}; use rustc_lint::{LateContext, LintContext}; use rustc_middle::{ hir::map::Map, lint::in_external_macro, ty::{self, Ty}, }; use rustc_span:...
hir::TyKind::Tup(tys) => tys.is_empty(), hir::TyKind::Never => true, _ => false, }, } } fn has_mutable_arg(cx: &LateContext<'_>, body: &hir::Body<'_>) -> bool { let mut tys = DefIdSet::default(); body.params.iter().any(|param| is_mutable_pat(cx, param.pat, &mut t...
match decl.output { hir::FnRetTy::DefaultReturn(_) => true, hir::FnRetTy::Return(ty) => match ty.kind {
random_line_split
must_use.rs
use rustc_ast::ast::Attribute; use rustc_errors::Applicability; use rustc_hir::def_id::{DefIdSet, LocalDefId}; use rustc_hir::{self as hir, def::Res, intravisit, QPath}; use rustc_lint::{LateContext, LintContext}; use rustc_middle::{ hir::map::Map, lint::in_external_macro, ty::{self, Ty}, }; use rustc_span:...
(cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'_>) { if let hir::ImplItemKind::Fn(ref sig, ref body_id) = item.kind { let is_public = cx.access_levels.is_exported(item.def_id); let fn_header_span = item.span.with_hi(sig.decl.output.span().hi()); let attrs = cx.tcx.hir().attrs(item.hir_i...
check_impl_item
identifier_name
must_use.rs
use rustc_ast::ast::Attribute; use rustc_errors::Applicability; use rustc_hir::def_id::{DefIdSet, LocalDefId}; use rustc_hir::{self as hir, def::Res, intravisit, QPath}; use rustc_lint::{LateContext, LintContext}; use rustc_middle::{ hir::map::Map, lint::in_external_macro, ty::{self, Ty}, }; use rustc_span:...
fn mutates_static<'tcx>(cx: &LateContext<'tcx>, body: &'tcx hir::Body<'_>) -> bool { let mut v = StaticMutVisitor { cx, mutates_static: false, }; intravisit::walk_expr(&mut v, &body.value); v.mutates_static }
{ use hir::ExprKind::{Field, Index, Path}; match e.kind { Path(QPath::Resolved(_, path)) => !matches!(path.res, Res::Local(_)), Path(_) => true, Field(inner, _) | Index(inner, _) => is_mutated_static(inner), _ => false, } }
identifier_body
dst-bad-coerce1.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} struct Foo; trait Bar {} pub fn main() { // With a vec of ints. let f1 = Fat { ptr: [1, 2, 3] }; let f2: &Fat<[int,..3]> = &f1; let f3: &Fat<[uint]> = f2; //~^ ERROR mismatched types: expected `&Fat<[uint]>`, found `&Fat<[int,..3]>` // With a trait. let f1 = Fat { ptr: Foo }; let f2...
// Attempt to change the type as well as unsizing. struct Fat<Sized? T> { ptr: T
random_line_split
dst-bad-coerce1.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
; trait Bar {} pub fn main() { // With a vec of ints. let f1 = Fat { ptr: [1, 2, 3] }; let f2: &Fat<[int,..3]> = &f1; let f3: &Fat<[uint]> = f2; //~^ ERROR mismatched types: expected `&Fat<[uint]>`, found `&Fat<[int,..3]>` // With a trait. let f1 = Fat { ptr: Foo }; let f2: &Fat<Foo> =...
Foo
identifier_name